coincidence.fixtures

Pytest fixtures.

To enable the fixtures add the following to conftest.py in your test directory:

pytest_plugins = ("coincidence", )

See the pytest documentation for more information.

Functions:

fixed_datetime(monkeypatch)

Pytest fixture to pretend the current datetime is 2:20 AM on 13th October 2020.

path_separator(request)

Parametrized pytest fixture which returns the current filesystem path separator and skips the test for the other.

tmp_pathplus(tmp_path)

Pytest fixture which returns a temporary directory in the form of a PathPlus object.

fixture fixed_datetime[source]

Scope:    function

Pytest fixture to pretend the current datetime is 2:20 AM on 13th October 2020.

See also

The with_fixed_datetime() contextmanager.

Attention

The monkeypatching only works when datetime is used and imported like:

import datetime
print(datetime.datetime.now())

Using from datetime import datetime won’t work.

Return type

Iterator

fixture path_separator[source]

Scope:    function

Parametrized pytest fixture which returns the current filesystem path separator and skips the test for the other.

This is useful when the test output differs on platforms with \ as the path separator, such as windows.

New in version 0.4.0.

Return type

str

fixture tmp_pathplus[source]

Scope:    function

Pytest fixture which returns a temporary directory in the form of a PathPlus object.

The directory is unique to each test function invocation, created as a sub directory of the base temporary directory.

Use it as follows:

pytest_plugins = ("coincidence", )

def test_something(tmp_pathplus: PathPlus):
    assert True
Return type

PathPlus