mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +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
|
@ -70,10 +70,10 @@ class TestProgram(object):
|
||||||
# defaults for testing
|
# defaults for testing
|
||||||
failfast = catchbreak = buffer = None
|
failfast = catchbreak = buffer = None
|
||||||
|
|
||||||
def __init__(self, module='__main__', defaultTest=None,
|
def __init__(self, module='__main__', defaultTest=None, argv=None,
|
||||||
argv=None, testRunner=None,
|
testRunner=None, testLoader=loader.defaultTestLoader,
|
||||||
testLoader=loader.defaultTestLoader, exit=True,
|
exit=True, verbosity=1, failfast=None, catchbreak=None,
|
||||||
verbosity=1, failfast=None, catchbreak=None, buffer=None):
|
buffer=None):
|
||||||
if isinstance(module, basestring):
|
if isinstance(module, basestring):
|
||||||
self.module = __import__(module)
|
self.module = __import__(module)
|
||||||
for part in module.split('.')[1:]:
|
for part in module.split('.')[1:]:
|
||||||
|
|
|
@ -1,10 +1,27 @@
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
class Test_TestProgram(unittest.TestCase):
|
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
|
# Horrible white box test
|
||||||
def testNoExit(self):
|
def testNoExit(self):
|
||||||
result = object()
|
result = object()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue