diff options
author | Ned Batchelder <nedbat@gmail.com> | 2015-04-24 21:06:26 -0400 |
---|---|---|
committer | Ned Batchelder <nedbat@gmail.com> | 2015-04-24 21:06:26 -0400 |
commit | 4cac18d36cd53c85f43ab79816b71cd2d4a3e6db (patch) | |
tree | 5741c738325d92c1a417b2c943f9b3f98f3417ba /coverage/test_helpers.py | |
parent | 3d88444cd3659fb93f17cbf4288c23bc82f33ead (diff) | |
parent | c3a98ff12933710d751ec28b984edb7936d457d3 (diff) | |
download | python-coveragepy-4cac18d36cd53c85f43ab79816b71cd2d4a3e6db.tar.gz |
Merged in lep/coverage.py (pull request #48)
Fix #363: crash when annotating non-ascii characters in python 2.
Diffstat (limited to 'coverage/test_helpers.py')
-rw-r--r-- | coverage/test_helpers.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/coverage/test_helpers.py b/coverage/test_helpers.py index 55a67a0..3f058b1 100644 --- a/coverage/test_helpers.py +++ b/coverage/test_helpers.py @@ -147,8 +147,15 @@ class TempDirMixin(SysPathAwareMixin, ModuleAwareMixin, TestCase): """ # Our own setting: most of these tests run in their own temp directory. + # Set this to False in your subclass if you don't want a temp directory + # created. run_in_temp_dir = True + # Set this if you aren't creating any files with make_file, but still want + # the temp directory. This will stop the test behavior checker from + # complaining. + no_files_in_temp_dir = False + def setUp(self): super(TempDirMixin, self).setUp() @@ -165,8 +172,8 @@ class TempDirMixin(SysPathAwareMixin, ModuleAwareMixin, TestCase): class_behavior = self.class_behavior() class_behavior.tests += 1 - class_behavior.test_method_made_any_files = False class_behavior.temp_dir = self.run_in_temp_dir + class_behavior.no_files_ok = self.no_files_in_temp_dir self.addCleanup(self.check_behavior) @@ -239,6 +246,7 @@ class TempDirMixin(SysPathAwareMixin, ModuleAwareMixin, TestCase): self.tests = 0 self.skipped = 0 self.temp_dir = True + self.no_files_ok = False self.tests_making_files = 0 self.test_method_made_any_files = False @@ -252,7 +260,8 @@ class TempDirMixin(SysPathAwareMixin, ModuleAwareMixin, TestCase): if behavior.tests <= behavior.skipped: bad = "" elif behavior.temp_dir and behavior.tests_making_files == 0: - bad = "Inefficient" + if not behavior.no_files_ok: + bad = "Inefficient" elif not behavior.temp_dir and behavior.tests_making_files > 0: bad = "Unsafe" else: |