conftest module

conftest.pytest_addoption(parser)[source]
conftest.pytest_configure(config)[source]
conftest.aws_config(pytestconfig)[source]
conftest.gcp_config(pytestconfig)[source]
conftest.pytest_runtest_setup(item)[source]

Add custom markers to pytest tests.

conftest.get_node_markers(node)[source]
exception conftest.DuplicateKeyError[source]

Bases: Exception

class conftest.SingleSet[source]

Bases: set

Set only allowing values to be added once

When addition of a duplicate value is detected, the DuplicateKeyError exception will be raised, all non duplicate values are added to the set.

Raises

DuplicateKeyError - when adding a value already in the set

>>> ss = SingleSet({1, 2, 3, 4})
>>> ss.add(3)
Traceback (most recent call last):
...
conftest.DuplicateKeyError: Value 3 already present
>>> ss.update({4, 5, 6, 3})
Traceback (most recent call last):
...
conftest.DuplicateKeyError: Value(s) {3, 4} already present
>>> ss
SingleSet({1, 2, 3, 4, 5, 6})
>>>

NB: - duplicate values on initialization are not detected >>> ss = SingleSet({1, 2, 3, 4, 3, 2, 1}) >>> ss SingleSet({1, 2, 3, 4})

add(value)[source]

Add an element to a set.

This has no effect if the element is already present.

update(values)[source]

Update a set with the union of itself and others.

conftest.serialize_datetimes(obj)[source]

Serializes datetimes to ISO format strings.

Used on report test_metadata since pytest-json doesn’t let us pass options to the serializer.

>>> from datetime import datetime
>>> serialize_datetimes({datetime(2000, 1, 1): -1})
{'2000-01-01T00:00:00': -1}
>>> serialize_datetimes({'foo': datetime(2000, 1, 1)})
{'foo': '2000-01-01T00:00:00'}
conftest.extract_metadata(resource)[source]
conftest.get_metadata_from_funcargs(funcargs)[source]
conftest.serialize_marker(marker)[source]
conftest.get_outcome_and_reason(report, markers, call)[source]
conftest.clean_docstring(docstr)[source]

Transforms a docstring into a properly formatted single line string.

>>> clean_docstring("\nfoo\n    bar\n")
'foo bar'
>>> clean_docstring("foo bar")
'foo bar'
conftest.pytest_runtest_makereport(item, call)[source]