plugin
ensembl.utils.plugin
¶
Ensembl's pytest plugin with useful unit testing hooks and fixtures.
fixture_assert_files()
¶
Returns a function that asserts if two text files are equal, or prints their differences.
Source code in src/ensembl/utils/plugin.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
fixture_db_factory(request, data_dir)
¶
Yields a unit test database factory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
FixtureRequest
|
Fixture that provides information of the requesting test function. |
required |
data_dir |
Path
|
Fixture that provides the path to the test data folder matching the test's name. |
required |
Source code in src/ensembl/utils/plugin.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
local_data_dir(request)
¶
Returns the path to the test data folder matching the test's name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
FixtureRequest
|
Fixture that provides information of the requesting test function. |
required |
Source code in src/ensembl/utils/plugin.py
75 76 77 78 79 80 81 82 83 |
|
pytest_addoption(parser)
¶
Registers argparse-style options for Ensembl's unit testing.
Pytest initialisation hook
<https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_addoption>
_.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parser |
Parser
|
Parser for command line arguments and ini-file values. |
required |
Source code in src/ensembl/utils/plugin.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
pytest_report_header(config)
¶
Presents extra information in the report header.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
Access to configuration values, pluginmanager and plugin hooks. |
required |
Source code in src/ensembl/utils/plugin.py
62 63 64 65 66 67 68 69 70 71 72 |
|
test_dbs(request, db_factory)
¶
Returns a dictionary of unit test databases with the database name as key.
Requires a list of dictionaries, each with keys src
(mandatory) and name
(optional), passed via
request.param
. See db_factory()
for details about each key's value. This fixture is a wrapper of
db_factory()
intended to be used via indirect parametrization, for example::
@pytest.mark.parametrize(
"test_dbs", [[{"src": "master"}, {"src": "master", "name": "master2"}]], indirect=True
)
def test_method(..., test_dbs: dict[str, UnitTestDB], ...):
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
FixtureRequest
|
Fixture that provides information of the requesting test function. |
required |
db_factory |
Callable
|
Fixture that provides a unit test database factory. |
required |
Source code in src/ensembl/utils/plugin.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|