test_unittest.py 文件源码

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

项目:GSM-scanner 作者: yosriayed 项目源码 文件源码
def test_setup(testdir):
    testpath = testdir.makepyfile("""
        import unittest
        class MyTestCase(unittest.TestCase):
            def setUp(self):
                self.foo = 1
            def setup_method(self, method):
                self.foo2 = 1
            def test_both(self):
                self.assertEquals(1, self.foo)
                assert self.foo2 == 1
            def teardown_method(self, method):
                assert 0, "42"

    """)
    reprec = testdir.inline_run("-s", testpath)
    assert reprec.matchreport("test_both", when="call").passed
    rep = reprec.matchreport("test_both", when="teardown")
    assert rep.failed and '42' in str(rep.longrepr)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号