mirror of
https://github.com/python/cpython.git
synced 2025-09-17 14:16:02 +00:00
Adding a test for unittest test discovery with dotted path name.
This commit is contained in:
parent
d1e696b60f
commit
215d394b82
2 changed files with 21 additions and 4 deletions
|
@ -1,10 +1,27 @@
|
|||
from cStringIO import StringIO
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
|
||||
class Test_TestProgram(unittest.TestCase):
|
||||
|
||||
def test_discovery_from_dotted_path(self):
|
||||
loader = unittest.TestLoader()
|
||||
|
||||
tests = [self]
|
||||
expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))
|
||||
|
||||
self.wasRun = False
|
||||
def _find_tests(start_dir, pattern):
|
||||
self.wasRun = True
|
||||
self.assertEqual(start_dir, expectedPath)
|
||||
return tests
|
||||
loader._find_tests = _find_tests
|
||||
suite = loader.discover('unittest.test')
|
||||
self.assertTrue(self.wasRun)
|
||||
self.assertEqual(suite._tests, tests)
|
||||
|
||||
# Horrible white box test
|
||||
def testNoExit(self):
|
||||
result = object()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue