mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue 7780. Adding a test for unittest test discovery from a dotted path.
This commit is contained in:
parent
cbf54b1e7e
commit
22097e4e66
1 changed files with 17 additions and 0 deletions
|
@ -341,5 +341,22 @@ class TestDiscovery(unittest.TestCase):
|
||||||
self.assertEqual(sys.path[0], full_path)
|
self.assertEqual(sys.path[0], full_path)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue