OLD | NEW |
(Empty) | |
| 1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 |
| 2 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt |
| 3 |
| 4 """A test base class for tests based on gold file comparison.""" |
| 5 |
| 6 import os |
| 7 import sys |
| 8 |
| 9 from tests.coveragetest import CoverageTest |
| 10 |
| 11 from coverage.test_helpers import change_dir # pylint: disable=unused-import |
| 12 from tests.test_farm import clean |
| 13 # Import helpers, eventually test_farm.py will go away. |
| 14 from tests.test_farm import ( # pylint: disable=unused-import |
| 15 compare, contains, doesnt_contain, contains_any, |
| 16 ) |
| 17 |
| 18 |
| 19 class CoverageGoldTest(CoverageTest): |
| 20 """A test based on gold files.""" |
| 21 |
| 22 run_in_temp_dir = False |
| 23 |
| 24 def setUp(self): |
| 25 super(CoverageGoldTest, self).setUp() |
| 26 self.chdir(self.root_dir) |
| 27 # Modules should be importable from the current directory. |
| 28 sys.path.insert(0, '') |
| 29 |
| 30 def output_dir(self, the_dir): |
| 31 """Declare where the output directory is. |
| 32 |
| 33 The output directory is deleted at the end of the test, unless the |
| 34 COVERAGE_KEEP_OUTPUT environment variable is set. |
| 35 |
| 36 """ |
| 37 self.addCleanup(self.cleanup_output_dir, the_dir) |
| 38 |
| 39 def cleanup_output_dir(self, the_dir): |
| 40 """Clean up the output directory of the test.""" |
| 41 if not os.environ.get("COVERAGE_KEEP_OUTPUT"): # pragma: partial |
| 42 clean(the_dir) |
OLD | NEW |