diff options
-rw-r--r-- | coverage/xmlreport.py | 2 | ||||
-rw-r--r-- | test/test_api.py | 32 | ||||
-rw-r--r-- | tox.ini | 4 |
3 files changed, 17 insertions, 21 deletions
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index a65d5a6..03f910c 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -114,7 +114,7 @@ class XmlReporter(Reporter): # Q: can we get info about the number of times a statement is # executed? If so, that should be recorded here. - xline.setAttribute("hits", str(int(not line in analysis.missing))) + xline.setAttribute("hits", str(int(line not in analysis.missing))) if self.arcs: if line in branch_stats: diff --git a/test/test_api.py b/test/test_api.py index 3f51188..8f27009 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -90,7 +90,7 @@ class SingletonApiTest(CoverageTest): class ApiTest(CoverageTest): """Api-oriented tests for Coverage.""" - def clean_files(self, files, *pats): + def clean_files(self, files, pats): """Remove names matching `pats` from `files`, a list of filenames.""" good = [] for f in files: @@ -101,10 +101,11 @@ class ApiTest(CoverageTest): good.append(f) return good - def listdir(self, where): - """Like os.listdir, but exclude files we don't care about.""" - files = os.listdir(where) - return self.clean_files(files, "*.pyc", "__pycache__") + def assertFiles(self, files): + """Assert that the files here are `files`, ignoring the usual junk.""" + here = os.listdir(".") + here = self.clean_files(here, ["*.pyc", "__pycache__"]) + self.assertSameElements(here, files) def test_unexecuted_file(self): cov = coverage.coverage() @@ -280,14 +281,13 @@ class ApiTest(CoverageTest): fooey = 17 """) - self.assertSameElements(self.listdir("."), ["datatest1.py"]) + self.assertFiles(["datatest1.py"]) cov = coverage.coverage() cov.start() self.import_local_file("datatest1") # pragma: recursive coverage cov.stop() # pragma: recursive coverage cov.save() - self.assertSameElements(self.listdir("."), - ["datatest1.py", ".coverage"]) + self.assertFiles(["datatest1.py", ".coverage"]) def test_datafile_specified(self): # You can specify the data file name. @@ -295,14 +295,13 @@ class ApiTest(CoverageTest): fooey = 17 """) - self.assertSameElements(self.listdir("."), ["datatest2.py"]) + self.assertFiles(["datatest2.py"]) cov = coverage.coverage(data_file="cov.data") cov.start() self.import_local_file("datatest2") # pragma: recursive coverage cov.stop() # pragma: recursive coverage cov.save() - self.assertSameElements(self.listdir("."), - ["datatest2.py", "cov.data"]) + self.assertFiles(["datatest2.py", "cov.data"]) def test_datafile_and_suffix_specified(self): # You can specify the data file name and suffix. @@ -310,14 +309,13 @@ class ApiTest(CoverageTest): fooey = 17 """) - self.assertSameElements(self.listdir("."), ["datatest3.py"]) + self.assertFiles(["datatest3.py"]) cov = coverage.coverage(data_file="cov.data", data_suffix="14") cov.start() self.import_local_file("datatest3") # pragma: recursive coverage cov.stop() # pragma: recursive coverage cov.save() - self.assertSameElements(self.listdir("."), - ["datatest3.py", "cov.data.14"]) + self.assertFiles(["datatest3.py", "cov.data.14"]) def test_datafile_from_rcfile(self): # You can specify the data file name in the .coveragerc file @@ -329,15 +327,13 @@ class ApiTest(CoverageTest): data_file = mydata.dat """) - self.assertSameElements(self.listdir("."), - ["datatest4.py", ".coveragerc"]) + self.assertFiles(["datatest4.py", ".coveragerc"]) cov = coverage.coverage() cov.start() self.import_local_file("datatest4") # pragma: recursive coverage cov.stop() # pragma: recursive coverage cov.save() - self.assertSameElements(self.listdir("."), - ["datatest4.py", ".coveragerc", "mydata.dat"]) + self.assertFiles(["datatest4.py", ".coveragerc", "mydata.dat"]) def test_empty_reporting(self): # Used to be you'd get an exception reporting on nothing... @@ -21,11 +21,11 @@ commands = {envpython} igor.py remove_extension # Test with the PyTracer - {envpython} igor.py test_with_tracer py + {envpython} igor.py test_with_tracer py {posargs} # Build the C extension and test with the CTracer {envpython} setup.py build_ext --inplace - {envpython} igor.py test_with_tracer c + {envpython} igor.py test_with_tracer c {posargs} deps = nose |