-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
module:test-suiteeverything related to our testseverything related to our tests
Description
As mentioned by @jnothman in #13846 (comment)
Relatedly, I proposed having a random_seed fixture that was globally set to different values on different testing runs. One benefit would be that we could easily distinguish those tests that are invariant under changing random seed from those that are brittle.
I think it would be a good idea. For instance, we could,
- create a global
auto-usepytest fixture inscikit-learn/conftest.py,@pytest.fixture(scope="session") def pytest_rng(): random_seed = os.environ.get('SKLEARN_TEST_RNG', 42) return np.random.RandomState(random_seed)
- modify tests to use it, e.g.
- def test_something(): + def test_something(pytest_rng): - rng = np.random.RandomState(0) - est = Estimator(random_state=rng) + est = Estimator(random_state=pytest_rng)
One issue is that global auto-use fixtures are a bit magical, but I'm hoping that naming it as pytest_rng it would be explicit enough.
Edit: updated to avoid using an auto-use fixture.
Metadata
Metadata
Assignees
Labels
module:test-suiteeverything related to our testseverything related to our tests