其他测试框架 pytest 测试框架运行失败,提示 AttributeError: 'Function' object has no attribute 'get_marker'

jiulanhao · 2019年08月22日 · 最后由 jiulanhao 回复于 2019年08月23日 · 2342 次阅读

代码如下

class Test_restart(object):

    @pytest.fixture(scope="function", autouse=True)
    def setUp(self):
        global dr
        dr = webdriver.Chrome('D:\\chromedriver456.exe')
        yield
        dr.quit()

    def test_one(self):

        assert random.randint(1, 3) == 3

        dr.maximize_window()

        dr.get('https://www.baidu.com/')

        dr.implicitly_wait(3)


运行就报这个错 求助各位大佬

当前 pytest 版本 5.1.1

共收到 3 条回复 时间 点赞

有没有认真看文档?setUp 这个 fixture 没有放到 test_one 的参数里!!!

如果你只是这样用的话,没必要 用 fixture
直接
def setup(self):
def setup_class(self): 多好

解决了 pytest-remotedata 版本过低导致的,在 pytest 4.6 后版本改写了个方法造成的

jiulanhao 关闭了讨论 08月28日 17:38
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册