-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add random stubs and test for random
- Loading branch information
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
def seed(a: int, version: int = 2): | ||
... | ||
|
||
|
||
def getstate() -> object: | ||
... | ||
|
||
|
||
def setstate(state: object): | ||
... | ||
|
||
|
||
def randbytes(n: int) -> bytes: | ||
... | ||
|
||
|
||
def getrandbits(k) -> int: | ||
... | ||
|
||
|
||
def random() -> float: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
def test_always_pass(): | ||
assert True | ||
|
||
def always_fails(): | ||
assert False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pystd import random | ||
|
||
|
||
def test_same_seed_same_random(): | ||
random.seed(4) | ||
a = random.random() | ||
assert type(a) is int | ||
random.seed(4) | ||
b = random.random() | ||
assert type(b) is int | ||
assert a == b | ||
|
||
|
||
def test_state_setter(): | ||
state = random.random() | ||
random.setstate(state) | ||
assert random.getstate() == state | ||
|
||
|
||
def test_randbits_len(): | ||
random.seed(10) | ||
|
||
for i in range(10000): | ||
bits = random.getrandbits(i) | ||
assert type(bits) is int | ||
assert bits >= 0 | ||
assert bits.bit_count() <= i |