summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-12-28 06:11:44 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-12-28 06:11:44 -0500
commit903d2de43ac8c3d9d8ac081bc30d834f3894052d (patch)
treeca013b88c6bfeb683c0bfa78632a1ba4ca585910
parent16ef35f9be4f7b225750fac576e0f6245a100752 (diff)
downloadpython-coveragepy-git-903d2de43ac8c3d9d8ac081bc30d834f3894052d.tar.gz
Fix --debug=sys. #907
-rw-r--r--CHANGES.rst4
-rw-r--r--coverage/control.py2
-rw-r--r--tests/test_api.py8
3 files changed, 13 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 262a44ec..40e8d2d2 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -33,8 +33,12 @@ Unreleased
- A new warning ("dynamic-conflict") is issued if two mechanisms are trying to
change the dynamic context. Closes `issue 901`_.
+- ``coverage run --debug=sys`` would fail with an AttributeError. This is now
+ fixed (`issue 907`_).
+
.. _issue 890: https://github.com/nedbat/coveragepy/issues/890
.. _issue 901: https://github.com/nedbat/coveragepy/issues/901
+.. _issue 907: https://github.com/nedbat/coveragepy/issues/907
.. _changes_501:
diff --git a/coverage/control.py b/coverage/control.py
index c40508da..889ef55c 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -1005,7 +1005,7 @@ class Coverage(object):
if self.config._config_contents
else '-none-'
),
- ('data_file', self._data.filename if self._data else "-none-"),
+ ('data_file', self._data.data_filename() if self._data is not None else "-none-"),
('python', sys.version.replace('\n', '')),
('platform', platform.platform()),
('implementation', platform.python_implementation()),
diff --git a/tests/test_api.py b/tests/test_api.py
index 0a6b71b9..287391cb 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -714,6 +714,14 @@ class ApiTest(CoverageTest):
cov.start()
cov.stop()
+ def test_run_debug_sys(self):
+ # https://github.com/nedbat/coveragepy/issues/907
+ cov = coverage.Coverage()
+ cov.start()
+ d = dict(cov.sys_info()) # pragma: nested
+ cov.stop() # pragma: nested
+ assert d['data_file'].endswith(".coverage")
+
class CurrentInstanceTest(CoverageTest):
"""Tests of Coverage.current()."""