Use of random.seed(n) in tests needs cleanup
Bug #891641 reported by
Brad Crittenden
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Fix Released
|
High
|
Brad Crittenden |
Bug Description
In the tests test_token_creation random.seed(0) is called in order to deterministically test token generation. That's fine but it make subsequent uses of random functions predictable.
Anytime random.seed(n) is called it must be reseeded by using random.seed() which is smart enough to do the right thing.
Related branches
lp:~bac/launchpad/bug-891641
- j.c.sackett (community): Approve
-
Diff: 36 lines (+7/-3)1 file modifiedlib/canonical/launchpad/tests/test_token_creation.py (+7/-3)
tags: |
added: qa-untestable removed: qa-needstesting |
Changed in launchpad: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
For other tests, rather than randomizing the state, I would recommend
doing random.getstate and then using a cleanup to pass that back to
random.setstate. That means the test is isolated and less likely to
cause order-dependent failures.