Skip to content

Commit

Permalink
Some cleanup from self review
Browse files Browse the repository at this point in the history
  • Loading branch information
aucampia committed Oct 24, 2021
1 parent 7f321b2 commit 8da5577
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docker-compose.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ services:
volumes:
- .:/rdflib
working_dir: /rdflib
command: ["python", "-m", "mypy", "--show-error-context", "--show-error-codes" ,"/rdflib/rdflib"]
command: ["python", "-m", "mypy", "--show-error-context", "--show-error-codes" ,"rdflib"]
2 changes: 1 addition & 1 deletion docs/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Run tests with `pytest <https://docs.pytest.org/en/latest/>`_:
$ pytest
Specific tests can be run by file name. For example::
Specific tests can be run by file name. For example:

.. code-block:: bash
Expand Down
13 changes: 11 additions & 2 deletions test/earl.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class EARL(DefinedNamespace):


class EarlReport:
"""
This is a helper class for building an EARL report graph.
"""

def __init__(
self,
asserter_uri: Optional[str] = None,
Expand Down Expand Up @@ -190,7 +194,7 @@ def pytest_unconfigure(config):
config.pluginmanager.unregister(earl)


# https://docs.pytest.org/en/6.2.x/reference.html#pytest.hookspec.pytest_runtest_protocol
# https://docs.pytest.org/en/latest/reference.html#pytest.hookspec.pytest_runtest_protocol


class TestResult(enum.Enum):
Expand All @@ -214,11 +218,16 @@ def get_rdf_test_uri(cls, report: "TestReport") -> Optional[URIRef]:


class EarlReporter:
"""
This class is a pytest plugin that will write a EARL report with results for
every pytest which has a rdf_test_uri parameter that is a string or an
URIRef.
"""

def __init__(self, output_path: Path, report: Optional[EarlReport] = None) -> None:
self.report = report if report is not None else EarlReport()
self.output_path = output_path

# @pytest.mark.hookwrapper
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(
self, item: Item, call: "CallInfo[None]"
Expand Down
9 changes: 0 additions & 9 deletions test/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,3 @@ def _str(x):
res,
syntax,
)


def pytest_manifest(subtests: SubTests, testers, manifest, base=None, legacy=False):
for _type, rdf_test_uri, rdf_test in read_manifest(manifest, base, legacy):
if _type in testers:
with subtests.test(
_type=_type, rdf_test_uri=rdf_test_uri, rdf_test=rdf_test
):
testers[_type](rdf_test)
5 changes: 5 additions & 0 deletions test/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ def test_example(self) -> None:


def eq_(lhs, rhs, msg=None):
"""
This function mimicks the similar function from nosetest. Ideally nothing
should use it but there is a lot of code that still does and it's fairly
simple to just keep this small pollyfill here for now.
"""
if msg:
assert lhs == rhs, msg
else:
Expand Down

0 comments on commit 8da5577

Please sign in to comment.