diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-11-09 17:19:42 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-11-09 19:42:42 -0500 |
commit | fc249034d7b8d7ac20b7f5fddde6f922442b2dfa (patch) | |
tree | c6e07c1cfb23e4126fce205fbee1fe856f85d2b5 | |
parent | da73d5a36f9eaff8e7d5e8d2d1d2c93a33ba6403 (diff) | |
download | python-coveragepy-git-fc249034d7b8d7ac20b7f5fddde6f922442b2dfa.tar.gz |
'[run] note' is no longer supported.
-rw-r--r-- | CHANGES.rst | 4 | ||||
-rw-r--r-- | coverage/control.py | 2 | ||||
-rw-r--r-- | coverage/sqldata.py | 10 | ||||
-rw-r--r-- | doc/config.rst | 4 | ||||
-rw-r--r-- | doc/whatsnew5x.rst | 4 | ||||
-rw-r--r-- | tests/coveragetest.py | 5 | ||||
-rw-r--r-- | tests/test_config.py | 11 | ||||
-rw-r--r-- | tests/test_data.py | 32 | ||||
-rw-r--r-- | tests/test_process.py | 23 |
9 files changed, 24 insertions, 71 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 53677148..48ee7f09 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -33,6 +33,10 @@ Unreleased settings in the ``[tool.coverage.]`` namespace. Thanks to Frazer McLean for implementation and persistence. Finishes `issue 664`_. +- The ``[run] note`` setting has been deprecated. Using it will result in a + warning, and the note will not be written to the data file. The + corresponding :class:`.CoverageData` methods have been removed. + - The HTML report has been reimplemented (no more table around the source code). This allowed for a better presentation of the context information, hopefully resolving `issue 855`_. diff --git a/coverage/control.py b/coverage/control.py index ff015882..7779fd3f 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -674,7 +674,7 @@ class Coverage(object): self._data.touch_file(file_path, plugin_name) if self.config.note: - self._data.add_run_info(note=self.config.note) + self._warn("The '[run] note' setting is no longer supported.") # Backward compatibility with version 1. def analysis(self, morf): diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 791dc77b..1c5ade40 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -5,7 +5,6 @@ # TODO: factor out dataop debugging to a wrapper class? # TODO: make sure all dataop debugging is in place somehow -# TODO: run_info import collections import datetime @@ -144,8 +143,7 @@ class CoverageData(SimpleReprMixin): To read a coverage.py data file, use :meth:`read`. You can then access the line, arc, or file tracer data with :meth:`lines`, :meth:`arcs`, - or :meth:`file_tracer`. Run information is available with - :meth:`run_infos`. + or :meth:`file_tracer`. The :meth:`has_arcs` method indicates whether arc data is available. You can get a list of the files in the data with :meth:`measured_files`. @@ -156,8 +154,7 @@ class CoverageData(SimpleReprMixin): Most data files will be created by coverage.py itself, but you can use methods here to create data files if you like. The :meth:`add_lines`, :meth:`add_arcs`, and :meth:`add_file_tracers` methods add data, in ways - that are convenient for coverage.py. The :meth:`add_run_info` method adds - key-value pairs to the run information. + that are convenient for coverage.py. To add a source file without any measured data, use :meth:`touch_file`. @@ -833,9 +830,6 @@ class CoverageData(SimpleReprMixin): lineno_contexts_map[lineno].append(context) return lineno_contexts_map - def run_infos(self): - return [] # TODO - @classmethod def sys_info(cls): """Our information for Coverage.sys_info. diff --git a/doc/config.rst b/doc/config.rst index f7483d06..ed0024cb 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -170,9 +170,7 @@ for details. .. _config_run_note: -``note`` (string): an arbitrary string that will be written to the data file. -You can use the :meth:`.CoverageData.run_infos` method to retrieve this string -from a data file. +``note`` (string): this is now obsolete. .. _config_run_omit: diff --git a/doc/whatsnew5x.rst b/doc/whatsnew5x.rst index 479895e2..c709d384 100644 --- a/doc/whatsnew5x.rst +++ b/doc/whatsnew5x.rst @@ -33,6 +33,10 @@ Backward Incompatibilities circumstances, you may need to use ``parallel=true`` to avoid multiple processes overwriting each others' data. +- The ``[run] note`` setting has been deprecated. Using it will result in a + warning, and the note will not be written to the data file. The + corresponding :class:`.CoverageData` methods have been removed. + - The deprecated `Reporter.file_reporters` property has been removed. - The reporting methods used to permanently apply their arguments to the diff --git a/tests/coveragetest.py b/tests/coveragetest.py index edb57356..4ffea0e6 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -99,11 +99,6 @@ class CoverageTest( self.last_command_output = None self.last_module_name = None - def skip_unless_data_storage_is(self, storage): - """Skip a test for tests that are particular about the storage implementation.""" - assert storage == "json" - self.skipTest("Some features haven't been implemented in SQL yet.") - def clean_local_file_imports(self): """Clean up the results of calls to `import_local_file`. diff --git a/tests/test_config.py b/tests/test_config.py index 0f9a4929..7979a84d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -396,6 +396,17 @@ class ConfigTest(CoverageTest): with self.assertRaisesRegex(CoverageException, msg): _ = coverage.Coverage() + def test_note_is_obsolete(self): + self.make_file("main.py", "a = 1") + self.make_file(".coveragerc", """\ + [run] + note = I am here I am here I am here! + """) + cov = coverage.Coverage() + with self.assert_warnings(cov, [r"The '\[run] note' setting is no longer supported."]): + self.start_import_stop(cov, "main") + cov.report() + class ConfigFileTest(UsingModulesMixin, CoverageTest): """Tests of the config file settings in particular.""" diff --git a/tests/test_data.py b/tests/test_data.py index 71e18bb9..d058388c 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -88,7 +88,6 @@ class DataTestHelpers(CoverageTest): self.assert_line_counts(covdata, SUMMARY_1) self.assert_measured_files(covdata, MEASURED_FILES_1) self.assertCountEqual(covdata.lines("a.py"), A_PY_LINES_1) - self.assertEqual(covdata.run_infos(), []) self.assertFalse(covdata.has_arcs()) def assert_arcs3_data(self, covdata): @@ -100,7 +99,6 @@ class DataTestHelpers(CoverageTest): self.assertCountEqual(covdata.lines("y.py"), Y_PY_LINES_3) self.assertCountEqual(covdata.arcs("y.py"), Y_PY_ARCS_3) self.assertTrue(covdata.has_arcs()) - self.assertEqual(covdata.run_infos(), []) class CoverageDataTest(DataTestHelpers, CoverageTest): @@ -214,15 +212,6 @@ class CoverageDataTest(DataTestHelpers, CoverageTest): covdata.contexts_by_lineno('a.py'), {1: ['test_a'], 2: ['test_a']}) - def test_run_info(self): - self.skip_unless_data_storage_is("json") - covdata = CoverageData() - self.assertEqual(covdata.run_infos(), []) - covdata.add_run_info(hello="there") - self.assertEqual(covdata.run_infos(), [{"hello": "there"}]) - covdata.add_run_info(count=17) - self.assertEqual(covdata.run_infos(), [{"hello": "there", "count": 17}]) - def test_no_duplicate_lines(self): covdata = CoverageData() covdata.set_context("context1") @@ -315,7 +304,6 @@ class CoverageDataTest(DataTestHelpers, CoverageTest): self.assert_line_counts(covdata3, SUMMARY_1_2) self.assert_measured_files(covdata3, MEASURED_FILES_1_2) - self.assertEqual(covdata3.run_infos(), []) def test_update_arcs(self): covdata1 = CoverageData(suffix='1') @@ -330,26 +318,6 @@ class CoverageDataTest(DataTestHelpers, CoverageTest): self.assert_line_counts(covdata3, SUMMARY_3_4) self.assert_measured_files(covdata3, MEASURED_FILES_3_4) - self.assertEqual(covdata3.run_infos(), []) - - def test_update_run_info(self): - self.skip_unless_data_storage_is("json") - covdata1 = CoverageData() - covdata1.add_arcs(ARCS_3) - covdata1.add_run_info(hello="there", count=17) - - covdata2 = CoverageData() - covdata2.add_arcs(ARCS_4) - covdata2.add_run_info(hello="goodbye", count=23) - - covdata3 = CoverageData() - covdata3.update(covdata1) - covdata3.update(covdata2) - - self.assertEqual(covdata3.run_infos(), [ - {'hello': 'there', 'count': 17}, - {'hello': 'goodbye', 'count': 23}, - ]) def test_update_cant_mix_lines_and_arcs(self): covdata1 = CoverageData(suffix='1') diff --git a/tests/test_process.py b/tests/test_process.py index 98134d2d..1579ec5e 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -16,7 +16,7 @@ from xml.etree import ElementTree import pytest import coverage -from coverage import env, CoverageData +from coverage import env from coverage.data import line_counts from coverage.misc import output_encoding @@ -711,27 +711,6 @@ class ProcessTest(CoverageTest): "(already-imported)").format(goodbye_path) self.assertIn(msg, out) - def test_note(self): - if env.PYPY and env.PY3 and env.PYPYVERSION[:3] == (5, 10, 0): # pragma: obscure - # https://bitbucket.org/pypy/pypy/issues/2729/pypy3-510-incorrectly-decodes-astral-plane - self.skipTest("Avoid incorrect decoding astral plane JSON chars") - self.skip_unless_data_storage_is("json") - - self.make_file(".coveragerc", """\ - [run] - data_file = mydata.dat - note = These are musical notes: ♫𝅗𝅥♩ - """) - self.make_file("simple.py", """print('hello')""") - self.run_command("coverage run simple.py") - - data = CoverageData("mydata.dat") - data.read() - infos = data.run_infos() - self.assertEqual(len(infos), 1) - expected = u"These are musical notes: ♫𝅗𝅥♩" - self.assertEqual(expected, infos[0]['note']) - @pytest.mark.expensive def test_fullcoverage(self): # pragma: no metacov if env.PY2: # This doesn't work on Python 2. |