GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `test_cmd` has `test_coverage` that does not work · Issue #111426 · python/cpython

test_cmd has test_coverage that does not work #111426

New issue
Copy link
New issue
Copy link
Closed
Closed
test_cmd has test_coverage that does not work#111426
Copy link
Assignees
sobolevn
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on Oct 28, 2023
Issue body actions

Bug report

cpython/Lib/test/test_cmd.py

Lines 251 to 262 in 2655369

def test_coverage(coverdir):
trace = support.import_module('trace')
tracer=trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,],
trace=0, count=1)
tracer.run('import importlib; importlib.reload(cmd); test_main()')
r=tracer.results()
print("Writing coverage results...")
r.write_results(show_missing=True, summary=True, coverdir=coverdir)
if __name__ == "__main__":
if "-c" in sys.argv:
test_coverage('/tmp/cmd.cover')

Output:

» ./python.exe Lib/test/test_cmd.py -c
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython2/Lib/test/test_cmd.py", line 262, in <module>
    test_coverage('/tmp/cmd.cover')
  File "/Users/sobolev/Desktop/cpython2/Lib/test/test_cmd.py", line 252, in test_coverage
    trace = support.import_module('trace')
            ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'test.support' has no attribute 'import_module'

Even, if refactored to:

def test_coverage(coverdir):
    from test.support import import_helper
    trace = import_helper.import_module('trace')
    tracer=trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,],
                        trace=0, count=1)
    tracer.run('import unittest; unittest.main()')
    r=tracer.results()
    print("Writing coverage results...")
    r.write_results(show_missing=True, summary=True, coverdir=coverdir)

It still does not work, no file is generated.

I propose to remove it, since -T works just fine:

» ./python.exe -m test -T test_cmd    
Using random seed: 2974785131
0:00:00 load avg: 1.22 Run 1 test sequentially
0:00:00 load avg: 1.22 [1/1] test_cmd

== Tests result: SUCCESS ==

1 test OK.

Total duration: 78 ms
Total tests: run=3
Total test files: run=1/1
Result: SUCCESS
lines   cov%   module   (path)
...
  236    63%   cmd   (/Users/sobolev/Desktop/cpython2/Lib/cmd.py)
...

I have a PR ready.

related #111348

Linked PRs

  • gh-111426: Remove test_cmd.test_coverage #111427
  • [3.12] gh-111426: Remove test_cmd.test_coverage (GH-111427) #111432
  • [3.11] gh-111426: Remove test_cmd.test_coverage (GH-111427) #111433

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Oct 28, 2023
  2. sobolevn
    self-assigned this
    on Oct 28, 2023
  3. sobolevn
    added a commit that references this issue on Oct 28, 2023

    pythongh-111426: Remove `test_cmd.test_coverage`

    5001690
  4. AlexWaygood
    added a commit that references this issue on Oct 28, 2023

    gh-111426: Remove `test_cmd.test_coverage` (#111427)

    66bea25
  5. miss-islington
    added 2 commits that reference this issue on Oct 28, 2023

    pythongh-111426: Remove `test_cmd.test_coverage` (pythonGH-111427)

    41d181d

    pythongh-111426: Remove `test_cmd.test_coverage` (pythonGH-111427)

    df1b0ed
  6. AlexWaygood
    added 2 commits that reference this issue on Oct 28, 2023

    [3.11] gh-111426: Remove `test_cmd.test_coverage` (GH-111427) (#111433)

    68c03ce

    [3.12] gh-111426: Remove `test_cmd.test_coverage` (GH-111427) (#111432)

    f7ce402
  7. AlexWaygood
    closed this as completedon Oct 28, 2023
  8. iritkatriel
    added a commit that references this issue on Oct 29, 2023

    pythongh-111426: Remove `test_cmd.test_coverage` (python#111427)

    d5ec031
  9. aisk
    added a commit that references this issue on Feb 11, 2024

    pythongh-111426: Remove `test_cmd.test_coverage` (python#111427)

    c1425bf
  10. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-111426: Remove `test_cmd.test_coverage` (python#111427)

    70d4a6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.