Skip to content

Fix and improve test_random #135376

Closed
Closed
@serhiy-storchaka

Description

@serhiy-storchaka

#135326 exposed the fact that there was no tests for objects implementing __index__ in test_random, even if some code in the random module explicitly support them.

When trying to add more tests, I discovered that

  • Some code is literally duplicated for Random and SystemRandom tests. It is easy to make error by modifying only only one of the copy.
  • As consequence of this, some tests were only added for SystemRandom, even if they are not specific for SystemRandom.

There was also no tests for randint().

So the following PR reorganizes test_random: removes duplicated code, makes sure that implementation agnostic tests are run for both classes, and add few new tests.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixestestsTests in the Lib/test dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions