mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-03-29 11:52:22 +00:00
chore: allow running dragonfly pytests in repeat (#3577)
This commit is contained in:
@ -19,6 +19,7 @@ You can override the location of the binary using `DRAGONFLY_PATH` environment v
|
||||
- use `--log-seeder file` to store all single-db commands from the lastest tests seeder inside file.
|
||||
- use `--existing-port` to use an existing instance for tests instead of starting one
|
||||
- use `--rand-seed` to set the global random seed. Makes the seeder predictable.
|
||||
- use `--repeat <N>` to run a test multiple times.
|
||||
|
||||
for example,
|
||||
|
||||
|
@ -276,6 +276,22 @@ def pytest_addoption(parser):
|
||||
default=None,
|
||||
help="Provide a port to the existing memcached process for the test",
|
||||
)
|
||||
parser.addoption("--repeat", action="store", help="Number of times to repeat each test")
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if metafunc.config.option.repeat is not None:
|
||||
count = int(metafunc.config.option.repeat)
|
||||
|
||||
# We're going to duplicate these tests by parametrizing them,
|
||||
# which requires that each test has a fixture to accept the parameter.
|
||||
# We can add a new fixture like so:
|
||||
metafunc.fixturenames.append("tmp_ct")
|
||||
|
||||
# Now we parametrize. This is what happens when we do e.g.,
|
||||
# @pytest.mark.parametrize('tmp_ct', range(count))
|
||||
# def test_foo(): pass
|
||||
metafunc.parametrize("tmp_ct", range(count))
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
Reference in New Issue
Block a user