def test_loadTestsFromNames__malformed_name(self):
loader = unittest2.TestLoader()
# XXX Should this raise ValueError or ImportError?
suite = loader.loadTestsFromNames(['abc () //'])
error, test = self.check_deferred_error(loader, list(suite)[0])
expected = "Failed to import test module: abc () //"
expected_regex = "Failed to import test module: abc \(\) //"
self.assertIn(
expected, error,
'missing error string in %r' % error)
self.assertRaisesRegex(
ImportError, expected_regex, getattr(test, 'abc () //'))
# "The specifier name is a ``dotted name'' that may resolve either to
# a module, a test case class, a TestSuite instance, a test method
# within a test case class, or a callable object which returns a
# TestCase or TestSuite instance."
#
# What happens when no module can be found for the given name?
test_loader.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录