From 8562aeb29eddf3349f5c363c1842f9822b18a450 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 10 Aug 2018 16:39:22 -0400 Subject: Move line_counts out of the data classes --- tests/test_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/test_api.py') diff --git a/tests/test_api.py b/tests/test_api.py index a860c7da..3e7e2f06 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -13,6 +13,7 @@ import warnings import coverage from coverage import env from coverage.backward import StringIO, import_local_file +from coverage.data import line_counts from coverage.misc import CoverageException from coverage.report import Reporter @@ -576,7 +577,7 @@ class SourceOmitIncludeTest(OmitIncludeTestsMixin, CoverageTest): import usepkgs # pragma: nested # pylint: disable=import-error, unused-variable cov.stop() # pragma: nested data = cov.get_data() - summary = data.line_counts() + summary = line_counts(data) for k, v in list(summary.items()): assert k.endswith(".py") summary[k[:-3]] = v -- cgit v1.2.1 From 19ec83bde56b6dfecef4ddae275376fdb4262e3a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 14 Aug 2018 20:39:57 -0400 Subject: Be flexible, and accept either json-sourced or sql-source error messages in some tests --- tests/test_api.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/test_api.py') diff --git a/tests/test_api.py b/tests/test_api.py index 3e7e2f06..854f9cc2 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -371,8 +371,12 @@ class ApiTest(CoverageTest): self.make_bad_data_file() cov = coverage.Coverage() warning_regex = ( + r"(" # JSON message: r"Couldn't read data from '.*\.coverage\.foo': " r"CoverageException: Doesn't seem to be a coverage\.py data file" + r"|" # SQL message: + r"Couldn't use data file '.*\.coverage\.foo': file is encrypted or is not a database" + r")" ) with self.assert_warnings(cov, [warning_regex]): cov.combine() -- cgit v1.2.1 From b701a0c3088f917e3fc5feb081a5b5166126d4f1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 23 Aug 2018 06:39:29 -0400 Subject: SQL storage means more tests need temp directories --- tests/test_api.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/test_api.py') diff --git a/tests/test_api.py b/tests/test_api.py index 854f9cc2..88da3468 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -512,8 +512,6 @@ class NamespaceModuleTest(UsingModulesMixin, CoverageTest): class OmitIncludeTestsMixin(UsingModulesMixin, CoverageTestMethodsMixin): """Test methods for coverage methods taking include and omit.""" - run_in_temp_dir = False - def filenames_in(self, summary, filenames): """Assert the `filenames` are in the keys of `summary`.""" for filename in filenames.split(): -- cgit v1.2.1 From 7ef5a0fa170dd96aa257924554473cedfb3ceae7 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 23 Aug 2018 20:11:54 -0400 Subject: Add a test emulating pytest-cov --- tests/test_api.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'tests/test_api.py') diff --git a/tests/test_api.py b/tests/test_api.py index 88da3468..05bde67c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -704,8 +704,6 @@ class TestRunnerPluginTest(CoverageTest): """ def pretend_to_be_nose_with_cover(self, erase): """This is what the nose --with-cover plugin does.""" - cov = coverage.Coverage() - self.make_file("no_biggie.py", """\ a = 1 b = 2 @@ -713,6 +711,7 @@ class TestRunnerPluginTest(CoverageTest): c = 4 """) + cov = coverage.Coverage() if erase: cov.combine() cov.erase() @@ -733,6 +732,34 @@ class TestRunnerPluginTest(CoverageTest): def test_nose_plugin_with_erase(self): self.pretend_to_be_nose_with_cover(erase=True) + def test_pytestcov_parallel(self): + self.make_file("prog.py", """\ + a = 1 + b = 2 + if b == 1: + c = 4 + """) + self.make_file(".coveragerc", """\ + [run] + parallel = True + source = . + """) + + cov = coverage.Coverage(source=None, branch=None, config_file='.coveragerc') + cov.erase() + self.start_import_stop(cov, "prog") + cov.combine() + cov.save() + report = StringIO() + cov.report(show_missing=None, ignore_errors=True, file=report, skip_covered=None) + self.assertEqual(report.getvalue(), textwrap.dedent("""\ + Name Stmts Miss Cover + ----------------------------- + prog.py 4 1 75% + """)) + self.assert_file_count(".coverage", 0) + self.assert_file_count(".coverage.*", 1) + class ReporterDeprecatedAttributeTest(CoverageTest): """Test that Reporter.file_reporters has been deprecated.""" -- cgit v1.2.1