Skip to content

Commit aa048f7

Browse files
Add documentation for primer and convert to command line option (#5387)
* Add documentation for primer and convert to command line option Co-authored-by: Jacob Walls <[email protected]>
1 parent fa7a84f commit aa048f7

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

.github/workflows/ci.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ jobs:
476476
. venv/bin/activate
477477
pytest --benchmark-disable tests/
478478
479-
pytest-primer-stlib:
479+
pytest-primer-stdlib:
480480
name: Run primer tests on stdlib Python ${{ matrix.python-version }} (Linux)
481481
runs-on: ubuntu-latest
482482
needs: prepare-tests-linux
@@ -508,7 +508,7 @@ jobs:
508508
run: |
509509
. venv/bin/activate
510510
pip install -e .
511-
pytest -m primer_stdlib -n auto
511+
pytest -m primer_stdlib --primer-stdlib -n auto
512512
513513
pytest-primer-external:
514514
name: Run primer tests on external libs Python ${{ matrix.python-version }} (Linux)
@@ -542,4 +542,4 @@ jobs:
542542
run: |
543543
. venv/bin/activate
544544
pip install -e .
545-
pytest -m primer_external -n auto
545+
pytest -m primer_external --primer-external -n auto

doc/development_guide/testing.rst

+20-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ current environment in order to have faster feedback. Run from Pylint root direc
8787

8888
python tests/test_functional.py
8989

90-
You can use all the options you would use for pytest, for example ``-k "test_functional[len_checks]"``.
90+
You can use all the options you would use for pytest_, for example ``-k "test_functional[len_checks]"``.
9191
Furthermore, if required the .txt file with expected messages can be regenerated based
9292
on the the current output by appending ``--update-functional-output`` to the command line::
9393

@@ -138,6 +138,25 @@ and should exit with exit code 2 the ``.out`` file should be named ``bad_configu
138138
The content of the ``.out`` file should have a similar pattern as a normal Pylint output. Note that the
139139
module name should be ``{abspath}`` and the file name ``{relpath}``.
140140

141+
Primer tests
142+
-------------------------------------------
143+
144+
Pylint also uses what we refer to as ``primer`` tests. These are tests that are run automatically
145+
in our Continuous Integration and check whether any changes in Pylint lead to crashes or fatal errors
146+
on the ``stdlib`` and a selection of external repositories.
147+
148+
To run the ``primer`` tests you can add either ``--primer-stdlib`` or ``--primer-external`` to the
149+
pytest_ command. If you want to only run the ``primer`` you can add either of their marks, for example::
150+
151+
pytest -m primer_external --primer-external
152+
153+
The list of repositories is created on the basis of three criteria: 1) projects need to use a diverse
154+
range of language features, 2) projects need to be well maintained and 3) projects should not have a codebase
155+
that is too repetitive. This guarantees a good balance between speed of our CI and finding potential bugs.
156+
157+
You can find the latest list of repositories and any relevant code for these tests in the ``tests/primer``
158+
directory.
159+
141160
.. _tox: https://tox.readthedocs.io/en/latest/
142161
.. _pytest: https://pytest.readthedocs.io/en/latest/
143162
.. _astroid: https://github.com/pycqa/astroid

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test = pytest
6969
[tool:pytest]
7070
testpaths = tests
7171
python_files = *test_*.py
72-
addopts = --strict-markers -m "not primer_stdlib and not primer_external"
72+
addopts = --strict-markers
7373
markers =
7474
primer_stdlib: Checks for crashes and errors when running pylint on stdlib
7575
primer_external: Checks for crashes and errors when running pylint on external libs

tests/conftest.py

+36
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,39 @@ def disable():
5656
@pytest.fixture(scope="module")
5757
def reporter():
5858
return MinimalTestReporter
59+
60+
61+
def pytest_addoption(parser) -> None:
62+
parser.addoption(
63+
"--primer-stdlib",
64+
action="store_true",
65+
default=False,
66+
help="Run primer stdlib tests",
67+
)
68+
parser.addoption(
69+
"--primer-external",
70+
action="store_true",
71+
default=False,
72+
help="Run primer external tests",
73+
)
74+
75+
76+
def pytest_collection_modifyitems(config, items) -> None:
77+
"""Convert command line options to markers"""
78+
# Add skip_primer_stdlib mark
79+
if not config.getoption("--primer-external"):
80+
skip_primer_external = pytest.mark.skip(
81+
reason="need --primer-external option to run"
82+
)
83+
for item in items:
84+
if "primer_external" in item.keywords:
85+
item.add_marker(skip_primer_external)
86+
87+
# Add skip_primer_stdlib mark
88+
if not config.getoption("--primer-stdlib"):
89+
skip_primer_stdlib = pytest.mark.skip(
90+
reason="need --primer-stdlib option to run"
91+
)
92+
for item in items:
93+
if "primer_stdlib" in item.keywords:
94+
item.add_marker(skip_primer_stdlib)

0 commit comments

Comments
 (0)