ts_lib_pytest.plugin module#
- get_uuid(count: int)[source]#
Create UUID-like string.
Example: get_uuid(123) -> “00000000-0000-0000-0000-000000000123”
- mock_uuid_generator(monkeypatch)[source]#
Pytest fixture that mocks UUID generation for consistent testing.
This fixture patches TaskScriptUUIDGenerator and related UUID functions to return predictable UUID strings in the format “00000000-0000-0000-0000-00000000000X” where X increments by 1 for each call starting from 1.
The fixture handles ImportError gracefully if task_script_utils is not available.
- Parameters:
monkeypatch – Pytest’s monkeypatch fixture for patching attributes
- pytest_addoption(parser: Parser)[source]#
Add custom command line options for the ts-lib-pytest plugin.
This pytest hook adds the –df-snapshot-update option which allows users to update DataFrame snapshots instead of comparing against existing ones.
- Parameters:
parser – The pytest argument parser to add options to
- df_snapshot(request: FixtureRequest) DataframeSnapshot[source]#
Pytest fixture that provides a DataframeSnapshot instance for snapshot testing.
This fixture automatically creates a snapshot file path based on the test file and test function name, following the pattern: <test_file_stem>_snapshots/<test_name>.parquet
The fixture checks for the –df-snapshot-update command line option (or –snapshot-update) to determine whether to update snapshots or compare against existing ones.
To control the snapshot file path, you can set DataframeSnapshot.path accordingly.
- Parameters:
request – The pytest FixtureRequest object containing test context
- Returns:
- An instance configured with the appropriate snapshot file path
and update mode based on command line options
- Return type: