Repository navigation
trace module cli does not write cover files #76089
Copy link
Copy link
Closed
Labels
3.7 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2017-10-31.02:55:06.847>
labels = ['3.7', 'type-bug', 'library']
title = 'trace module cli does not write cover files'
updated_at = <Date 2018-08-11.06:28:37.697>
user = 'https://bugs.python.org/MichaelSelik'bugs.python.org fields:
activity = <Date 2018-08-11.06:28:37.697>
actor = 'berker.peksag'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2017-10-31.02:55:06.847>
creator = 'Michael Selik'
dependencies = []
files = []
hgrepos = []
issue_num = 31908
keywords = ['patch']
message_count = 13.0
messages = ['305268', '305269', '305341', '305343', '305347', '305367', '306173', '315980', '315981', '315984', '323058', '323401', '323403']
nosy_count = 8.0
nosy_names = ['rhettinger', 'belopolsky', 'berker.peksag', 'serhiy.storchaka', 'selik', 'Michael Selik', 'ZackerySpytz', 'miss-islington']
pr_nums = ['4205', '6666', '6667', '6668', '8664', '8732']
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue31908'
versions = ['Python 3.6', 'Python 3.7']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.7 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
MichaelSelik commentedon Oct 31, 2017
The trace module command-line utility doesn't write cover files. I've noticed this issue for some years now. It works fine in Python 2. When using Python 3, no ".cover" files are written, regardless of how "--coverdir" is specified.
My apologies if this is a duplicate bug. I searched the tracker and Google for a while, but couldn't find a relevant issue.
rhettinger commentedon Oct 31, 2017
It worked in Python 3.4, but not afterwards.
MichaelSelik commentedon Oct 31, 2017
The problem appears to be a mistake in commit f026dae
f026dae
This made the writing of cover files conditional on
show_missingwhich is the option to mark lines which weren't executed with several angle brackets ">>>>>".https://github.com/python/cpython/blob/3.5/Lib/trace.py#L326
MichaelSelik commentedon Nov 1, 2017
While writing a patch for this, I noticed the
lnotabparameter seems nearly unused. It's a dict, but is only used for its keys.https://github.com/python/cpython/blob/master/Lib/trace.py#L333
Further, the choice to count unreached lines only when
show_missingwas set seems inconsistent.https://github.com/python/cpython/blob/master/Lib/trace.py#L335
https://github.com/python/cpython/blob/master/Lib/trace.py#L280
MichaelSelik commentedon Nov 1, 2017
Ok, pull request submitted:
#4205
berkerpeksag commentedon Nov 1, 2017
I think the first part of your patch also fixes bpo-26818. Could you adapt the test there and add a test case for the problem in this issue?
selik commentedon Nov 13, 2017
You're referring to something like this:
+ def test_count_and_summary(self):
+ name = TESTFN + '.py'
+ with open(name, 'w') as fd:
+ self.addCleanup(unlink, name)
+ fd.write("""\
+x = 1
+y = 2
+
+def f():
+ return x + y
+
+for i in range(10):
+ f()
+ """)
+ status, stdout, stderr = assert_python_ok('-m', 'trace', '-cs', name)
+ self.assertEqual(status, 0)
+ self.assertIn(b'lines cov% module (path)', stdout)
+ self.assertIn(('6 100%% %s (%s)' % (TESTFN, name)).encode(), stdout)
+
?
serhiy-storchaka commentedon May 1, 2018
New changeset 47ab154 by Serhiy Storchaka (Michael Selik) in branch 'master':
bpo-31908: Fix output of cover files for trace module command-line tool. (GH-4205)
47ab154
miss-islington commentedon May 1, 2018
New changeset e4eeb6e by Miss Islington (bot) in branch '3.7':
bpo-31908: Fix output of cover files for trace module command-line tool. (GH-4205)
e4eeb6e
miss-islington commentedon May 1, 2018
New changeset a607f8b by Miss Islington (bot) in branch '3.6':
bpo-31908: Fix output of cover files for trace module command-line tool. (GH-4205)
a607f8b
ZackerySpytz commentedon Aug 3, 2018
This change causes test_trace to leave a trace.cover file in the Lib directory (see bpo-34171).
berkerpeksag commentedon Aug 11, 2018
New changeset c8b0dbc by Berker Peksag in branch 'master':
bpo-26818: Add a test to make sure the bug is fixed (GH-8664)
c8b0dbc
berkerpeksag commentedon Aug 11, 2018
New changeset 8fc21c8 by Berker Peksag (Miss Islington (bot)) in branch '3.7':
bpo-26818: Add a test to make sure the bug is fixed (GH-8664)
8fc21c8