Skip to content

Instantly share code, notes, and snippets.

@wilfreddesert
Created December 28, 2020 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilfreddesert/99d839192228f6a7b2eaf2ec66aa472a to your computer and use it in GitHub Desktop.
Save wilfreddesert/99d839192228f6a7b2eaf2ec66aa472a to your computer and use it in GitHub Desktop.
import pytest
import random
@pytest.fixture
def make_rnd_gen():
def _get_result(seed, mode):
# Hint: use pytest.fixture
if mode == 0:
return random.Random(seed).randint(-1000, 1000)
elif mode == 1:
return random.Random(seed ** 2).randint(-1000, 1000)
elif mode == 2:
return random.Random(seed).randint(1, 50)
elif mode == 3:
return random.Random(seed ** 2).gauss(0, 5)
else:
return random.Random(seed).choice(range(10000))
return _get_result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment