Api

This part of the documentation lists the full API reference of all public classes and functions.

fixtup.up(fixture: str, keep_mounted_fixture: bool = False) Generator[None, None, None]

Mount a fixture to use it in a test.

The mounted fixture is removed either at when the context is closed, either when the python process has finished to run depending of the fixture policy.

If you want to keep the mounted context to debug the impact of the code inside the mounted fixture, set keep_mounted_fixture at True.

>>> with fixtup.up('thumbnail_context'):
>>>     os.chdir(wd)
>>>     # do something ...
Parameters:
  • fixture – the identifier of the fixture, it’s the name of the directory that define the fixture

  • keep_mounted_fixture – don’t remove the directory of mounted fixture at the end of the context

fixtup.configure(settings: dict) None

configure the module fixtup to override configuration

You should prefer configure fixtup using python manifest like setup.cfg or pyproject.toml.

>>> import os
>>>
>>> import fixtup
>>>
>>> SCRIPT_DIR = os.directory.realpath(os.directory.join(__file__, '..'))
>>> fixtup.configure({"fixtures": os.directory.join(SCRIPT_DIR, "../fixtures")})
Parameters:

settings – a key value dictionary that specify the settings of fixtup

Helper

fixtup.helper.wait_port(port: int, host: str = 'localhost', timeout: int | None = None, attempt_every: int = 100) None

wait until a port would be open, for example the port 5432 for postgresql before going further

>>> fixtup.helper.wait_port(5432, timeout=5000)
Parameters:
  • port – port that has to be open

  • remote_ip – host on which the port has to be open. It will be localhost by default

  • timeout – timeout in ms before raising TimeoutError.

  • attempt_every – time in ms between each attempt to check if the port is responding

fixtup.helper.wait_readiness(url: str, timeout: int | None = None, attempt_every: int = 1000, predicate: Callable[[Response], bool] | None = None) None

wait until a url reply to http request with 200.

>>> fixtup.helper.base.wait_readiness(
>>>         'http://localhost:9000/probes/readz',
>>>         timeout=5000)
Parameters:
  • url – port that has to be open

  • timeout – timeout in ms before raising TimeoutError.

  • attempt_every – time in ms between each attempt to check if the port is responding (default 1000ms)

  • predicate – a function that takes the request response and check if the result is valid