Skip to content

Commit

Permalink
Make all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
fxrlxrn committed Jun 3, 2023
1 parent b7df7e7 commit e21247d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions pystd/random.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
from typing import Sequence

import time
_seed = 4


def seed(a: int = None, version: int = 2):
def seed(a=None, version: int = 2):
global _seed
if a is None:
_seed = int(time.time())
_seed = a


def getstate() -> object:
...
global _seed
return _seed


def setstate(state: object):
...
global _seed
_seed = int(state)


def getrandbits(k) -> int:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_same_seed_same_random():


def test_state_setter():
state = random.random()
state = random.randint(0, 100)
random.setstate(state)
assert random.getstate() == state

Expand Down

0 comments on commit e21247d

Please sign in to comment.