我有一個複合,價格昂貴但價格便宜的策略。我必須這樣做:Python假設 - 爲許多測試構建策略一次?
@given(expensive_strategy())
def test_all(x):
assert...
assert...
...
建立示例和運行斷言的時間可以忽略不計4秒。
最佳做法決定將這些測試分開。
我不清楚我如何可以結合假設策略和例如。 TestCase.setUp或pytest會話範圍的燈具。裝飾夾具和呼叫x = expensive_strategy(); @given(x)
都沒有幫助。
['會議範圍的燈具](https://docs.pytest.org/en/latest/fixture.html#sharing-a-fixture-across-tests-in-a-module-or-類會議)? –