test_loader.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:devsecops-example-helloworld 作者: boozallen 项目源码 文件源码
def test_loadTestsFromNames__callable__call_staticmethod(self):
        m = types.ModuleType('m')
        class Test1(unittest2.TestCase):
            def test(self):
                pass

        testcase_1 = Test1('test')
        class Foo(unittest2.TestCase):
            @staticmethod
            def foo():
                return testcase_1
        m.Foo = Foo

        loader = unittest2.TestLoader()
        suite = loader.loadTestsFromNames(['Foo.foo'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        ref_suite = unittest2.TestSuite([testcase_1])
        self.assertEqual(list(suite), [ref_suite])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a TestCase or TestSuite instance"
    #
    # What happens when the callable returns something else?
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号