Skip to content

Commit

Permalink
text: fix pytest config
Browse files Browse the repository at this point in the history
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 reas ...

This patch fixes this situation by moving the pytest
config from `tox.ini` to `setup.cfg`.

Also:
- remove the pytest ignore on `test/translate_algebra` as tests in there
  have been running and passing for some time.
  • Loading branch information
aucampia committed Apr 18, 2022
1 parent 8a92d35 commit 1a6bb34
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ exclude = '''
)/
)
'''

[tool.pytest.ini_options]
addopts = [
"--doctest-modules",
"--ignore=admin",
"--ignore=rdflib/extras/external_graph_libs.py",
"--ignore-glob=docs/*.py",
]
doctest_optionflags = "ALLOW_UNICODE"
filterwarnings = [
# The below warning is a consequence of how pytest doctest detects mocks and how DefinedNamespace behaves when an undefined attribute is being accessed.
"ignore:Code. pytest_mock_example_attribute_that_shouldnt_exist is not defined in namespace .*:UserWarning",
# The below warning is a consequence of how pytest detects fixtures and how DefinedNamespace behaves when an undefined attribute is being accessed.
"ignore:Code. _pytestfixturefunction is not defined in namespace .*:UserWarning",
]
# log_cli = true
# log_cli_level = "DEBUG"
log_cli_format = "%(asctime)s %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s"
log_cli_date_format = "%Y-%m-%dT%H:%M:%S"
2 changes: 1 addition & 1 deletion rdflib/plugins/parsers/nquads.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
>>> from rdflib import ConjunctiveGraph, URIRef, Namespace
>>> g = ConjunctiveGraph()
>>> data = open("test/nquads.rdflib/example.nquads", "rb")
>>> data = open("test/data/nquads.rdflib/example.nquads", "rb")
>>> g.parse(data, format="nquads") # doctest:+ELLIPSIS
<Graph identifier=... (<class 'rdflib.graph.Graph'>)>
>>> assert len(g.store) == 449
Expand Down
14 changes: 0 additions & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,3 @@ skip =
build,
dist,
venv,

[tool:pytest]
addopts =
--doctest-modules
--ignore=test/translate_algebra
--ignore=admin
--ignore=rdflib/extras/external_graph_libs.py
--ignore-glob=docs/*.py
doctest_optionflags = ALLOW_UNICODE
filterwarnings =
# The below warning is a consequence of how pytest doctest detects mocks and how DefinedNamespace behaves when an undefined attribute is being accessed.
ignore:Code. pytest_mock_example_attribute_that_shouldnt_exist is not defined in namespace .*:UserWarning
# The below warning is a consequence of how pytest detects fixtures and how DefinedNamespace behaves when an undefined attribute is being accessed.
ignore:Code. _pytestfixturefunction is not defined in namespace .*:UserWarning
6 changes: 0 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,3 @@ passenv = HOMEPATH # needed on Windows
commands =
precommit: pre-commit run
precommitall: pre-commit run --all-files

[pytest]
# log_cli = true
# log_cli_level = DEBUG
log_cli_format = %(asctime)s %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s
log_cli_date_format=%Y-%m-%dT%H:%M:%S

0 comments on commit 1a6bb34

Please sign in to comment.