Ticket #3481: trial-marker.diff
| File trial-marker.diff, 2.2 KB (added by jonathanj, 10 months ago) |
|---|
-
twisted/trial/test/test_runner.py
477 477 self.assertEqual(['runcall'], debugger._calls) 478 478 479 479 480 def test_noMarker(self): 481 """ 482 Specifying a temp directory that does not have a trial marker results 483 in an exception and does not remove the specified directory. 484 """ 485 tempPath = self.mktemp() 486 # Create our working directory outside of trial. 487 os.mkdir(tempPath) 488 self.parseOptions(['--temp-directory', tempPath, 489 'twisted.trial.test.sample']) 490 my_runner = self.getRunner() 491 loader = runner.TestLoader() 492 suite = loader.loadByName('twisted.trial.test.sample', True) 493 self.assertRaises(runner.NoTrialMarker, my_runner.run, suite) 494 self.assertTrue(os.path.exists(tempPath)) 480 495 496 497 481 498 class TestTrialSuite(unittest.TestCase): 482 499 483 500 def test_imports(self): -
twisted/trial/runner.py
40 40 41 41 42 42 43 class NoTrialMarker(Exception): 44 """ 45 No trial marker file could be found. 46 """ 47 48 49 43 50 def isPackage(module): 44 51 """Given an object return True if the object looks like a package""" 45 52 if not isinstance(module, types.ModuleType): … … 697 704 698 705 699 706 def _removeSafely(self, path): 707 """ 708 Safely remove a path, recursively. 709 710 If C{path} does not contain a node named C{_trial_marker}, a 711 C{NoTrialmarker} exception is raised and the path is not removed. 712 """ 713 if not os.path.exists(os.path.join(path, '_trial_marker')): 714 raise NoTrialMarker( 715 '%r is not a trial temporary path, refusing to remove it' 716 % (path,)) 717 700 718 try: 701 719 shutil.rmtree(path) 702 720 except OSError, e: … … 739 757 740 758 os.mkdir(testdir) 741 759 os.chdir(testdir) 760 file('_trial_marker', 'w').close() 742 761 return currentDir 743 762 744 763
