def test_the_same_random_seed_per_test_can_be_turned_off(ourtestdir):
ourtestdir.makepyfile(
test_one="""
import random
def test_a():
test_a.state1 = random.getstate()
assert test_a.state1 == random.getstate() # sanity check
assert random.random() >= 0 # mutate state
test_a.state2 = random.getstate()
def test_b():
test_b.state = random.getstate()
assert test_b.state == random.getstate() # sanity check
assert test_a.state1 != test_b.state
assert test_a.state2 == test_b.state
"""
)
out = ourtestdir.runpytest(
'--randomly-dont-reset-seed', '--randomly-dont-reorganize',
)
out.assert_outcomes(passed=2, failed=0)
评论列表
文章目录