在一种测试方法中使用Monkeypatch

时间:2019-07-08 11:19:00

标签: python pytest python-unittest monkeypatching

我正在尝试在测试类中的测试函数中获取monkeypatch上的句柄:

class TestClass(unittest.TestCase)
    def test_method(self, monkeypatch):
        monkeypatch.setattr('sys.path', something)

我希望能够在测试方法中进行特定的修补,但不能在整个课程中继续使用。有办法解决这个问题吗?

我尝试这样做:

@pytest.fixture(autouse=True)
@def test_method(self, monkeypatch)
似乎不允许

0 个答案:

没有答案
相关问题