Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,15 @@ The tests compare algorithm variants with known OEIS values and exercise generat

### Test your own algorithms with the mapFolding tests

A package that counts with `mapFolding`, or generates its own modules with `mapFolding.kitAST`, can use the fixtures of `mapFolding.tests` as an ordinary pytest plugin. Add `mapFolding[testing]` to its testing dependencies, then register the plugin in the root `conftest.py` of its tests:
A package that counts with `mapFolding`, or generates its own modules with `mapFolding.kitAST`, can use the fixtures of `mapFolding.tests` as an ordinary pytest plugin. Add `mapFolding[testing]` to its testing dependencies, then register the plugin in the `conftest.py` of the tests directory that `testpaths` names, or in the `conftest.py` at the root of the repository:

```python
pytest_plugins = ('mapFolding.tests.conftest',)
```

Each test receives the fixtures by name. `expected` is a(n) of the test's `oeisID` and `n` parameters, read from the b-file that `mapFolding.oeis` stores, and `identifiers` gives a module generator a `pathRoot` that one test owns:
pytest accepts `pytest_plugins` only in a `conftest.py` that it loads at startup. The tests directory's `conftest.py` travels with a tests package in the wheel, and it works for `pytest`, `pytest yourPackage`, a path inside the tests directory, and `pytest --pyargs yourPackage.tests`; `pytest .` fails with "Defining 'pytest_plugins' in a non-top-level conftest". A root `conftest.py` works for every run inside the repository, but not for an installed tests package.

Each test receives the fixtures by name. `expected` is a(n) of the test's `oeisID` and `n` parameters, and `cellsKnown` is row n of the triangle `oeisID`, each read from the b-file that `mapFolding.oeis` stores. `identifiers` gives a module generator a `pathRoot` that one test owns. A fixture of the same name in your own `conftest.py` hides the plugin's, and a parameter that a test parametrizes directly overrides a fixture of the same name; a parameter named `triangle` that a test does not parametrize receives the A400429 triangle.

```python
from itertools import product as CartesianProduct
Expand Down
8 changes: 6 additions & 2 deletions mapFolding/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@

Another package that counts or generates with `mapFolding` tests its own algorithms with this infrastructure:
- Its testing dependencies include `mapFolding[testing]`, which installs everything that this package's tests import.
- Its root `conftest.py` registers this suite's fixtures as a plugin: `pytest_plugins = ('mapFolding.tests.conftest',)`.
- The `conftest.py` of its tests directory, which `testpaths` names, registers this suite's fixtures as a plugin:
`pytest_plugins = ('mapFolding.tests.conftest',)`. pytest accepts `pytest_plugins` only in a conftest that it loads at startup,
so `pytest .` at the repository root fails, and `pytest`, `pytest <package>`, a path inside the tests directory, and `--pyargs`
work. A root `conftest.py` works for every run inside the repository, but an installed tests package lacks it.
- Its `tests/__init__.py` re-exports the assertion helpers of `hunterMakesPy.tests`, and the helpers here that it uses.
- Its tests receive the fixtures by name. `expected` is a(n) of the `oeisID` and `n` parameters, from the stored b-file;
- Its tests receive the fixtures by name, and its own fixtures take other names, because a local fixture hides the plugin's.
`expected` is a(n) of the `oeisID` and `n` parameters, and `cellsKnown` is row n of the triangle `oeisID`, from the stored b-file;
`identifiers` gives a generator a `pathRoot` that one test owns; `albumKnown`, `arrayFoldings`, and `pathAlbum` read the
albums and enumerated foldings in `dataSamples`, which the distribution includes.
"""
Expand Down
5 changes: 3 additions & 2 deletions mapFolding/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Fixtures that own temporary files, package state, the processor total, a command, and expensive immutable objects.

Another package that counts with `mapFolding` receives these fixtures by registering this module as a plugin in its root
`conftest.py`: `pytest_plugins = ('mapFolding.tests.conftest',)`.
Another package that counts with `mapFolding` receives these fixtures by registering this module as a plugin in a `conftest.py`
that pytest loads at startup, such as the one in the tests directory that its `testpaths` names:
`pytest_plugins = ('mapFolding.tests.conftest',)`.
"""
from __future__ import annotations

Expand Down