Commit 215d394b authored by Michael Foord's avatar Michael Foord

Adding a test for unittest test discovery with dotted path name.

parent d1e696b6
...@@ -70,10 +70,10 @@ class TestProgram(object): ...@@ -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:]:
......
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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment