-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from mdekstrand/feature/stdlib-rng
Add API to create stdlib Random instances
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 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
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,33 @@ | ||
""" | ||
stdlib python tests | ||
""" | ||
|
||
import random | ||
|
||
from seedbank import std_rng | ||
|
||
|
||
def test_stdlib_rng(): | ||
""" | ||
Make sure we get an stdlib RNG. | ||
""" | ||
rng = std_rng() | ||
assert isinstance(rng, random.Random) | ||
|
||
|
||
def test_stdlib_rng_fresh_seed(): | ||
""" | ||
Test that two stdlib RNGs with fresh seeds return different numbers. | ||
""" | ||
rng1 = std_rng() | ||
rng2 = std_rng() | ||
assert rng1.getrandbits(10) != rng2.getrandbits(10) | ||
|
||
|
||
def test_stdlib_rng_same_seed(): | ||
""" | ||
Test that two stdlib RNGs with the same seed start the same. | ||
""" | ||
rng1 = std_rng("foo") | ||
rng2 = std_rng("foo") | ||
assert rng1.getrandbits(10) == rng2.getrandbits(10) |