Giter Club home page Giter Club logo

Comments (3)

adamchainz avatar adamchainz commented on September 7, 2024

What if there was a pytest fixture or context manager? Then we could have

@pytest.mark.parametrize('seed', [9001, 1337])
def test_old_bad_seeds(seed, randomly):
    randomly.reseed(seed)
    # test that has failed in the past with those exact seeds

Tbh I'm not that excited about this though. I think if you find a failing test with a particular seed, it's not the seed that should be turned into a new test case but the actual underlying data that caused the failure. For example if seed 9001 caused your data generator to create a user with a really long name, add a test with a user with a fixed really long name.

Fixing the seed in a test run is pretty fragile, as the data generator could change in the future, meaning the seed values don't mean the same thing, so the tests could stop testing the specific bugs they exposed. For example, new versions of faker come with new data, remapping the data returned for a given seed.

Do you have a use case that prevents making tests with fixed test data, or at makes it impractical?

from pytest-randomly.

sobolevn avatar sobolevn commented on September 7, 2024

Fixing the seed in a test run is pretty fragile, as the data generator could change in the future, meaning the seed values don't mean the same thing, so the tests could stop testing the specific bugs they exposed

Yeap, that seems reasonable. hypothesis spoiled me here.
I will stick to the data examples.

from pytest-randomly.

adamchainz avatar adamchainz commented on September 7, 2024

Btw hypothesis has @example for this - https://hypothesis.readthedocs.io/en/latest/reproducing.html#providing-explicit-examples . But that can't have an analog in pytest-randomly because we don't touch data generation :)

from pytest-randomly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.