fixture.py 文件源码

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

项目:GSM-scanner 作者: yosriayed 项目源码 文件源码
def test_scoped(self, testdir):
        testdir.makepyfile("""
            import pytest
            @pytest.yield_fixture(scope="module")
            def arg1():
                print ("setup")
                yield 1
                print ("teardown")
            def test_1(arg1):
                print ("test1 %s" % arg1)
            def test_2(arg1):
                print ("test2 %s" % arg1)
        """)
        result = testdir.runpytest("-s")
        result.stdout.fnmatch_lines("""
            *setup*
            *test1 1*
            *test2 1*
            *teardown*
        """)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号