Commits

Ned Batchelder  committed 72decc5

All tests should restore sys.path

  • Participants
  • Parent commits 0b6f3e6

Comments (0)

Files changed (2)

File test/coveragetest.py

     run_in_temp_dir = True
 
     def setUp(self):
+        # tearDown will restore the original sys.path
+        self.old_syspath = sys.path[:]
+
         if self.run_in_temp_dir:
             # Create a temporary directory.
             self.noise = str(random.random())[2:]
             self.old_dir = os.getcwd()
             os.chdir(self.temp_dir)
 
-
             # Modules should be importable from this temp directory.
-            self.old_syspath = sys.path[:]
             sys.path.insert(0, '')
 
             # Keep a counter to make every call to check_coverage unique.
         self.old_modules = dict(sys.modules)
 
     def tearDown(self):
+        # Restore the original sys.path.
+        sys.path = self.old_syspath
+
         if self.run_in_temp_dir:
-            # Restore the original sys.path.
-            sys.path = self.old_syspath
-
             # Get rid of the temporary directory.
             os.chdir(self.old_dir)
             shutil.rmtree(self.temp_root)

File test/test_summary.py

         sys.path.append(self.nice_file(os.path.dirname(__file__), 'modules'))
 
     def test_empty_files(self):
+        # Shows that empty files like __init__.py are listed as having zero
+        # statements, not one statement.
         cov = coverage.coverage()
         cov.start()
         import usepkgs                      # pylint: disable=F0401,W0612