| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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.
mike on macbook in ~/
$ echo 'print("hello")' > foo.py
mike on macbook in ~/
$ python -m trace --count foo.py
hello
mike on macbook in ~/
$ ls *.cover
ls: *.cover: No such file or directory
My apologies if this is a duplicate bug. I searched the tracker and Google for a while, but couldn't find a relevant issue.
It worked in Python 3.4, but not afterwards.
The problem appears to be a mistake in commit f026dae
This made the writing of cover files conditional on show_missing which 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
mike on mac in ~/ $ python -m trace --count foo.py hello mike on mac in ~/ $ ls *.cover ls: *.cover: No such file or directory mike on mac in ~/ $ python -m trace --count -m foo.py hello mike on mac in ~/ $ ls *.cover -rw-r--r-- 1 mike staff 22B Oct 31 15:40 foo.cover
While writing a patch for this, I noticed the lnotab parameter 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_missing was 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
Ok, pull request submitted:
#4205
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?
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)
+
?
This change causes test_trace to leave a trace.cover file in the Lib directory (see bpo-34171).
| Back | FazBrowse Home | New Git URL |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more detailsGitHub fields:
bugs.python.org fields: