Skip to content

Commit be32bb6

Browse files
committed
text: fix pytest config
pytest was using config from `tox.ini` preferentially and ignoring config from `setup.cfg`, as a side-effect doctests were not running on code/docstrings in `rdflib/`. The reason why some pytest config was in `tox.ini` instead of `setup.cfg` was because of these issues: - pypa/pip#5182 - pytest-dev/pytest#3062 As a compromise to fix this I have opted for moving all pytest config to `pyproject.toml`: - https://docs.pytest.org/en/stable/reference/customize.html#pyproject-toml This seems sensible as `pyproject.toml` is standarized by PEPs and eventually most things from `setup.cfg` will end up in there anyway. Also: - remove the pytest ignore on `test/translate_algebra` as tests in there have been running and passing for some time. - fixed path to test data in `rdflib/plugins/parsers/nquads.py`.
1 parent 8a92d35 commit be32bb6

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,22 @@ exclude = '''
2828
)/
2929
)
3030
'''
31+
32+
[tool.pytest.ini_options]
33+
addopts = [
34+
"--doctest-modules",
35+
"--ignore=admin",
36+
"--ignore=rdflib/extras/external_graph_libs.py",
37+
"--ignore-glob=docs/*.py",
38+
]
39+
doctest_optionflags = "ALLOW_UNICODE"
40+
filterwarnings = [
41+
# The below warning is a consequence of how pytest doctest detects mocks and how DefinedNamespace behaves when an undefined attribute is being accessed.
42+
"ignore:Code. pytest_mock_example_attribute_that_shouldnt_exist is not defined in namespace .*:UserWarning",
43+
# The below warning is a consequence of how pytest detects fixtures and how DefinedNamespace behaves when an undefined attribute is being accessed.
44+
"ignore:Code. _pytestfixturefunction is not defined in namespace .*:UserWarning",
45+
]
46+
# log_cli = true
47+
# log_cli_level = "DEBUG"
48+
log_cli_format = "%(asctime)s %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s"
49+
log_cli_date_format = "%Y-%m-%dT%H:%M:%S"

rdflib/plugins/parsers/nquads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
>>> from rdflib import ConjunctiveGraph, URIRef, Namespace
77
>>> g = ConjunctiveGraph()
8-
>>> data = open("test/nquads.rdflib/example.nquads", "rb")
8+
>>> data = open("test/data/nquads.rdflib/example.nquads", "rb")
99
>>> g.parse(data, format="nquads") # doctest:+ELLIPSIS
1010
<Graph identifier=... (<class 'rdflib.graph.Graph'>)>
1111
>>> assert len(g.store) == 449

setup.cfg

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,3 @@ skip =
7070
build,
7171
dist,
7272
venv,
73-
74-
[tool:pytest]
75-
addopts =
76-
--doctest-modules
77-
--ignore=test/translate_algebra
78-
--ignore=admin
79-
--ignore=rdflib/extras/external_graph_libs.py
80-
--ignore-glob=docs/*.py
81-
doctest_optionflags = ALLOW_UNICODE
82-
filterwarnings =
83-
# The below warning is a consequence of how pytest doctest detects mocks and how DefinedNamespace behaves when an undefined attribute is being accessed.
84-
ignore:Code. pytest_mock_example_attribute_that_shouldnt_exist is not defined in namespace .*:UserWarning
85-
# The below warning is a consequence of how pytest detects fixtures and how DefinedNamespace behaves when an undefined attribute is being accessed.
86-
ignore:Code. _pytestfixturefunction is not defined in namespace .*:UserWarning

tox.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,3 @@ passenv = HOMEPATH # needed on Windows
4343
commands =
4444
precommit: pre-commit run
4545
precommitall: pre-commit run --all-files
46-
47-
[pytest]
48-
# log_cli = true
49-
# log_cli_level = DEBUG
50-
log_cli_format = %(asctime)s %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s
51-
log_cli_date_format=%Y-%m-%dT%H:%M:%S

0 commit comments

Comments
 (0)