Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure pytest #1268

Closed
wants to merge 7 commits into from
Closed

Conversation

white-gecko
Copy link
Member

@white-gecko white-gecko commented Mar 1, 2021

This needs to be rebased after #1267 is merged.

Proposed Changes

  • Remove nose
  • Use pytest

Nose has been in maintenance mode for the past several years and will likely cease without a new person/team to take over maintainership. New projects should consider using Nose2, py.test, or just plain unittest/unittest2. (https://nose.readthedocs.io/en/latest/#note-to-users)

The test coverage is not the same, some tests are not yet executed.

Check: https://docs.pytest.org/en/stable/nose.html

yield tests are not supported by pytest. (This was how they worked in nose) Some are changed to direct calls, but maybe we want to actually have test generators in these cases. We might use https://hypothesis.readthedocs.io/en/latest/quickstart.html for this.

The migration is no simple task. Additional contributions are very welcome!

@coveralls
Copy link

Coverage Status

Coverage decreased (-12.8%) to 62.62% when pulling 99373eb on white-gecko:feature/pytest into 9f0f296 on RDFLib:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-12.8%) to 62.62% when pulling 99373eb on white-gecko:feature/pytest into 9f0f296 on RDFLib:master.

@FlorianLudwig
Copy link
Contributor

One thing that I like to do is to include the tests folder in coverage.

This does skew the overall coverage number but it does help to spot parts of the tests that are not executed.

- python setup.py install
- flake8 --exit-zero rdflib
- PYTHONWARNINGS=default nosetests --with-timer --timer-top-n 42 --with-coverage --cover-tests --cover-package=rdflib
- coverage run -m pytest
Copy link
Contributor

@FlorianLudwig FlorianLudwig Mar 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have a look at pytest-cov

It gives a report directly in the logs but also can produce additional reports (xml for coveralls and html for other use cases)

@westurner
Copy link
Contributor

https://pypi.org/project/python-coveralls/

https://pytest-cov.readthedocs.io/en/latest/reporting.html

@aucampia
Copy link
Member

To clarify the scope here, I presume the goal is to get rid of everything nose related?

@aucampia
Copy link
Member

I looked a bit at the test generation from test/manifest.py. I think the easiest way to map this to pytest is to use https://github.com/pytest-dev/pytest-subtests

Would like to get some feedback here before moving forward with that though.

@white-gecko white-gecko added the help wanted Extra attention is needed label Jul 17, 2021
@kloczek
Copy link

kloczek commented Jul 21, 2021

Just for the record below i pyyest log on top of 6.0.0.
pytest is failing in units which requires berkeleydb module.
Currently most of the Linux distributions are trying move away from BDB and use instead for example sqlite.
There are some number of pytest warnings.

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-rdflib-6.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-rdflib-6.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -k '      not test_service and    not test_service_with_bind and  not test_service_with_values'
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, hypothesis-6.14.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, Faker-8.10.0
collected 592 items / 7 deselected / 585 selected

. .                                                                                                                                                                  [  0%]
test/test_aggregate_graphs.py .                                                                                                                                      [  0%]
test/test_auditable.py ........................                                                                                                                      [  4%]
test/test_b64_binary.py .                                                                                                                                            [  4%]
test/test_batch_add.py ..........                                                                                                                                    [  6%]
test/test_canonicalization.py ...x                                                                                                                                   [  7%]
test/test_comparison.py ..........                                                                                                                                   [  8%]
test/test_conjunctive_graph.py ..x                                                                                                                                   [  9%]
test/test_container.py .................                                                                                                                             [ 12%]
test/test_conventions.py .                                                                                                                                           [ 12%]
test/test_create_input_source.py ..                                                                                                                                  [ 12%]
test/test_csv2rdf.py ..                                                                                                                                              [ 13%]
test/test_dataset.py sss...                                                                                                                                          [ 14%]
test/test_datetime.py .......                                                                                                                                        [ 15%]
test/test_dawg.py x                                                                                                                                                  [ 15%]
test/test_diff.py ..x                                                                                                                                                [ 15%]
test/test_duration.py ......                                                                                                                                         [ 16%]
test/test_empty_xml_base.py ..                                                                                                                                       [ 17%]
test/test_evaluate_bind.py x                                                                                                                                         [ 17%]
test/test_events.py .                                                                                                                                                [ 17%]
test/test_expressions.py ......                                                                                                                                      [ 18%]
test/test_extras_external_graph_libs.py ss                                                                                                                           [ 19%]
test/test_finalnewline.py .                                                                                                                                          [ 19%]
test/test_graph.py sssssssss.........                                                                                                                                [ 22%]
test/test_graph_context.py ssssssssss..........                                                                                                                      [ 25%]
test/test_graph_formula.py x                                                                                                                                         [ 25%]
test/test_graph_http.py ..                                                                                                                                           [ 26%]
test/test_graph_items.py .                                                                                                                                           [ 26%]
test/test_graph_operator.py ...                                                                                                                                      [ 26%]
test/test_hex_binary.py ..                                                                                                                                           [ 27%]
test/test_initbindings.py ..........................                                                                                                                 [ 31%]
test/test_issue084.py ........                                                                                                                                       [ 33%]
test/test_issue1043.py .                                                                                                                                             [ 33%]
test/test_issue1141.py ...                                                                                                                                           [ 33%]
test/test_issue1160.py .                                                                                                                                             [ 33%]
test/test_issue160.py .                                                                                                                                              [ 34%]
test/test_issue161.py .                                                                                                                                              [ 34%]
test/test_issue184.py .                                                                                                                                              [ 34%]
test/test_issue190.py ss                                                                                                                                             [ 34%]
test/test_issue200.py .                                                                                                                                              [ 34%]
test/test_issue209.py .                                                                                                                                              [ 35%]
test/test_issue223.py .                                                                                                                                              [ 35%]
test/test_issue247.py ..                                                                                                                                             [ 35%]
test/test_issue248.py .                                                                                                                                              [ 35%]
test/test_issue274.py .................................                                                                                                              [ 41%]
test/test_issue363.py ..                                                                                                                                             [ 41%]
test/test_issue379.py ..                                                                                                                                             [ 42%]
test/test_issue381.py .......                                                                                                                                        [ 43%]
test/test_issue432.py .                                                                                                                                              [ 43%]
test/test_issue446.py .                                                                                                                                              [ 43%]
test/test_issue492.py .                                                                                                                                              [ 43%]
test/test_issue523.py .                                                                                                                                              [ 44%]
test/test_issue532.py .                                                                                                                                              [ 44%]
test/test_issue535.py .                                                                                                                                              [ 44%]
test/test_issue545.py .                                                                                                                                              [ 44%]
test/test_issue554.py .                                                                                                                                              [ 44%]
test/test_issue563.py ..                                                                                                                                             [ 45%]
test/test_issue579.py .                                                                                                                                              [ 45%]
test/test_issue604.py .                                                                                                                                              [ 45%]
test/test_issue655.py .                                                                                                                                              [ 45%]
test/test_issue715.py .                                                                                                                                              [ 45%]
test/test_issue733.py ..                                                                                                                                             [ 46%]
test/test_issue801.py .                                                                                                                                              [ 46%]
test/test_issue910.py ....                                                                                                                                           [ 46%]
test/test_issue920.py .                                                                                                                                              [ 47%]
test/test_issue923.py .                                                                                                                                              [ 47%]
test/test_issue953.py .                                                                                                                                              [ 47%]
test/test_issue977.py ..                                                                                                                                             [ 47%]
test/test_issue_git_200.py .                                                                                                                                         [ 47%]
test/test_issue_git_336.py .                                                                                                                                         [ 48%]
test/test_literal.py ..................x                                                                                                                             [ 51%]
test/test_memory_store.py ..                                                                                                                                         [ 51%]
test/test_mulpath_n3.py .                                                                                                                                            [ 51%]
test/test_n3.py ................                                                                                                                                     [ 54%]
test/test_n3_suite.py x                                                                                                                                              [ 54%]
test/test_namespace.py ........x..........                                                                                                                           [ 58%]
test/test_nodepickler.py ...                                                                                                                                         [ 58%]
test/test_normalizedString.py ....                                                                                                                                   [ 59%]
test/test_nquads.py ...........                                                                                                                                      [ 61%]
test/test_nquads_w3c.py x                                                                                                                                            [ 61%]
test/test_nt_misc.py ......................                                                                                                                          [ 65%]
test/test_nt_w3c.py x                                                                                                                                                [ 65%]
test/test_parse_file_guess_format.py ...                                                                                                                             [ 65%]
test/test_parser.py ....                                                                                                                                             [ 66%]
test/test_parser_helpers.py .                                                                                                                                        [ 66%]
test/test_parser_reads_from_pathlike_object.py .                                                                                                                     [ 66%]
test/test_path_div_future.py .                                                                                                                                       [ 66%]
test/test_prefixTypes.py .                                                                                                                                           [ 67%]
test/test_preflabel.py .....                                                                                                                                         [ 67%]
test/test_prettyxml.py .......                                                                                                                                       [ 69%]
test/test_rdf_lists.py ..                                                                                                                                            [ 69%]
test/test_rdfxml.py ..                                                                                                                                               [ 69%]
test/test_roundtrip.py xx                                                                                                                                            [ 70%]
test/test_seq.py ..                                                                                                                                                  [ 70%]
test/test_serialize.py ..                                                                                                                                            [ 70%]
test/test_serializexml.py .....                                                                                                                                      [ 71%]
test/test_slice.py .                                                                                                                                                 [ 71%]
test/test_sparql.py .........                                                                                                                                        [ 73%]
test/test_sparql_agg_distinct.py ....                                                                                                                                [ 74%]
test/test_sparql_agg_undef.py x.                                                                                                                                     [ 74%]
test/test_sparql_construct_bindings.py .                                                                                                                             [ 74%]
test/test_sparql_datetime.py ....                                                                                                                                    [ 75%]
test/test_sparql_operators.py ...                                                                                                                                    [ 75%]
test/test_sparql_parser.py ..                                                                                                                                        [ 76%]
test/test_sparqlstore.py ........                                                                                                                                    [ 77%]
test/test_sparqlupdatestore.py ssssssssssss                                                                                                                          [ 79%]
test/test_sparqlupdatestore_mock.py .                                                                                                                                [ 79%]
test/test_store_berkeleydb.py FFFFFF                                                                                                                                 [ 80%]
test/test_swap_n3.py x                                                                                                                                               [ 80%]
test/test_term.py .......                                                                                                                                            [ 82%]
test/test_tokendatatype.py .....                                                                                                                                     [ 83%]
test/test_trig.py .........s.                                                                                                                                        [ 84%]
test/test_trig_w3c.py x                                                                                                                                              [ 85%]
test/test_trix_parse.py ...                                                                                                                                          [ 85%]
test/test_trix_serialize.py ..                                                                                                                                       [ 85%]
test/test_tsvresults.py .                                                                                                                                            [ 86%]
test/test_turtle_serialize.py .....                                                                                                                                  [ 86%]
test/test_turtle_sort_issue613.py ..                                                                                                                                 [ 87%]
test/test_turtle_w3c.py x                                                                                                                                            [ 87%]
test/test_util.py ............................x...............                                                                                                       [ 95%]
test/test_wide_python.py .                                                                                                                                           [ 95%]
test/test_xmlliterals.py ....                                                                                                                                        [ 95%]
test/jsonld/test_api.py .                                                                                                                                            [ 96%]
test/jsonld/test_compaction.py x                                                                                                                                     [ 96%]
test/jsonld/test_context.py ................                                                                                                                         [ 98%]
test/jsonld/test_localsuite.py x                                                                                                                                     [ 99%]
test/jsonld/test_named_graphs.py ...                                                                                                                                 [ 99%]
test/jsonld/test_onedotone.py x                                                                                                                                      [ 99%]
test/jsonld/test_testsuite.py x                                                                                                                                      [100%]

================================================================================= FAILURES =================================================================================
____________________________________________________________________ BerkeleyDBTestCase.test_multigraph ____________________________________________________________________

self = <test.test_store_berkeleydb.BerkeleyDBTestCase testMethod=test_multigraph>

    def setUp(self):
        self.store_name = "BerkeleyDB"
        self.path = mktemp()
>       self.g = ConjunctiveGraph(store=self.store_name)

test/test_store_berkeleydb.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rdflib/graph.py:1500: in __init__
    super(ConjunctiveGraph, self).__init__(store, identifier=identifier)
rdflib/graph.py:303: in __init__
    self.__store = store = plugin.get(store, Store)()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <rdflib.plugins.stores.berkeleydb.BerkeleyDB object at 0x7fb666c25370>, configuration = None, identifier = None

    def __init__(self, configuration=None, identifier=None):
        if not has_bsddb:
>           raise ImportError("Unable to import berkeleydb, store is unusable.")
E           ImportError: Unable to import berkeleydb, store is unusable.

rdflib/plugins/stores/berkeleydb.py:69: ImportError
____________________________________________________________________ BerkeleyDBTestCase.test_open_shut _____________________________________________________________________

self = <test.test_store_berkeleydb.BerkeleyDBTestCase testMethod=test_open_shut>

    def setUp(self):
        self.store_name = "BerkeleyDB"
        self.path = mktemp()
>       self.g = ConjunctiveGraph(store=self.store_name)

test/test_store_berkeleydb.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rdflib/graph.py:1500: in __init__
    super(ConjunctiveGraph, self).__init__(store, identifier=identifier)
rdflib/graph.py:303: in __init__
    self.__store = store = plugin.get(store, Store)()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <rdflib.plugins.stores.berkeleydb.BerkeleyDB object at 0x7fb666db41c0>, configuration = None, identifier = None

    def __init__(self, configuration=None, identifier=None):
        if not has_bsddb:
>           raise ImportError("Unable to import berkeleydb, store is unusable.")
E           ImportError: Unable to import berkeleydb, store is unusable.

rdflib/plugins/stores/berkeleydb.py:69: ImportError
_______________________________________________________________________ BerkeleyDBTestCase.test_read _______________________________________________________________________

self = <test.test_store_berkeleydb.BerkeleyDBTestCase testMethod=test_read>

    def setUp(self):
        self.store_name = "BerkeleyDB"
        self.path = mktemp()
>       self.g = ConjunctiveGraph(store=self.store_name)

test/test_store_berkeleydb.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rdflib/graph.py:1500: in __init__
    super(ConjunctiveGraph, self).__init__(store, identifier=identifier)
rdflib/graph.py:303: in __init__
    self.__store = store = plugin.get(store, Store)()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <rdflib.plugins.stores.berkeleydb.BerkeleyDB object at 0x7fb666b5a850>, configuration = None, identifier = None

    def __init__(self, configuration=None, identifier=None):
        if not has_bsddb:
>           raise ImportError("Unable to import berkeleydb, store is unusable.")
E           ImportError: Unable to import berkeleydb, store is unusable.

rdflib/plugins/stores/berkeleydb.py:69: ImportError
__________________________________________________________________ BerkeleyDBTestCase.test_sparql_insert ___________________________________________________________________

self = <test.test_store_berkeleydb.BerkeleyDBTestCase testMethod=test_sparql_insert>

    def setUp(self):
        self.store_name = "BerkeleyDB"
        self.path = mktemp()
>       self.g = ConjunctiveGraph(store=self.store_name)

test/test_store_berkeleydb.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rdflib/graph.py:1500: in __init__
    super(ConjunctiveGraph, self).__init__(store, identifier=identifier)
rdflib/graph.py:303: in __init__
    self.__store = store = plugin.get(store, Store)()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <rdflib.plugins.stores.berkeleydb.BerkeleyDB object at 0x7fb67f72fcd0>, configuration = None, identifier = None

    def __init__(self, configuration=None, identifier=None):
        if not has_bsddb:
>           raise ImportError("Unable to import berkeleydb, store is unusable.")
E           ImportError: Unable to import berkeleydb, store is unusable.

rdflib/plugins/stores/berkeleydb.py:69: ImportError
___________________________________________________________________ BerkeleyDBTestCase.test_sparql_query ___________________________________________________________________

self = <test.test_store_berkeleydb.BerkeleyDBTestCase testMethod=test_sparql_query>

    def setUp(self):
        self.store_name = "BerkeleyDB"
        self.path = mktemp()
>       self.g = ConjunctiveGraph(store=self.store_name)

test/test_store_berkeleydb.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rdflib/graph.py:1500: in __init__
    super(ConjunctiveGraph, self).__init__(store, identifier=identifier)
rdflib/graph.py:303: in __init__
    self.__store = store = plugin.get(store, Store)()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <rdflib.plugins.stores.berkeleydb.BerkeleyDB object at 0x7fb67fa0baf0>, configuration = None, identifier = None

    def __init__(self, configuration=None, identifier=None):
        if not has_bsddb:
>           raise ImportError("Unable to import berkeleydb, store is unusable.")
E           ImportError: Unable to import berkeleydb, store is unusable.

rdflib/plugins/stores/berkeleydb.py:69: ImportError
______________________________________________________________________ BerkeleyDBTestCase.test_write _______________________________________________________________________

self = <test.test_store_berkeleydb.BerkeleyDBTestCase testMethod=test_write>

    def setUp(self):
        self.store_name = "BerkeleyDB"
        self.path = mktemp()
>       self.g = ConjunctiveGraph(store=self.store_name)

test/test_store_berkeleydb.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
rdflib/graph.py:1500: in __init__
    super(ConjunctiveGraph, self).__init__(store, identifier=identifier)
rdflib/graph.py:303: in __init__
    self.__store = store = plugin.get(store, Store)()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <rdflib.plugins.stores.berkeleydb.BerkeleyDB object at 0x7fb67fc63df0>, configuration = None, identifier = None

    def __init__(self, configuration=None, identifier=None):
        if not has_bsddb:
>           raise ImportError("Unable to import berkeleydb, store is unusable.")
E           ImportError: Unable to import berkeleydb, store is unusable.

rdflib/plugins/stores/berkeleydb.py:69: ImportError
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/_pytest/fixtures.py:223
  /usr/lib/python3.8/site-packages/_pytest/fixtures.py:223: UserWarning: Code: _pytestfixturefunction is not defined in namespace XSD
    fixturemarker: Optional[FixtureFunctionMarker] = getattr(

test/test_conjunctive_graph.py:49
  test/test_conjunctive_graph.py:49: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_graph_ids will be ignored
    def test_graph_ids():

test/test_dawg.py:516
  test/test_dawg.py:516: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_dawg will be ignored
    def test_dawg():

test/test_evaluate_bind.py:8
  test/test_evaluate_bind.py:8: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_bind will be ignored
    def test_bind():

test/test_graph_formula.py:129
  test/test_graph_formula.py:129: PytestCollectionWarning: yield tests were removed in pytest 4.0 - testFormulaStores will be ignored
    def testFormulaStores():

../../../../../usr/lib/python3.8/site-packages/_pytest/fixtures.py:223
  /usr/lib/python3.8/site-packages/_pytest/fixtures.py:223: UserWarning: Code: _pytestfixturefunction is not defined in namespace DCAT
    fixturemarker: Optional[FixtureFunctionMarker] = getattr(

../../../../../usr/lib/python3.8/site-packages/_pytest/fixtures.py:223
  /usr/lib/python3.8/site-packages/_pytest/fixtures.py:223: UserWarning: Code: _pytestfixturefunction is not defined in namespace PROF
    fixturemarker: Optional[FixtureFunctionMarker] = getattr(

../../../../../usr/lib/python3.8/site-packages/_pytest/fixtures.py:223
  /usr/lib/python3.8/site-packages/_pytest/fixtures.py:223: UserWarning: Code: _pytestfixturefunction is not defined in namespace SDO
    fixturemarker: Optional[FixtureFunctionMarker] = getattr(

../../../../../usr/lib/python3.8/site-packages/_pytest/fixtures.py:223
  /usr/lib/python3.8/site-packages/_pytest/fixtures.py:223: UserWarning: Code: _pytestfixturefunction is not defined in namespace SOSA
    fixturemarker: Optional[FixtureFunctionMarker] = getattr(

../../../../../usr/lib/python3.8/site-packages/_pytest/fixtures.py:223
  /usr/lib/python3.8/site-packages/_pytest/fixtures.py:223: UserWarning: Code: _pytestfixturefunction is not defined in namespace SSN
    fixturemarker: Optional[FixtureFunctionMarker] = getattr(

../../../../../usr/lib/python3.8/site-packages/_pytest/fixtures.py:223
  /usr/lib/python3.8/site-packages/_pytest/fixtures.py:223: UserWarning: Code: _pytestfixturefunction is not defined in namespace TIME
    fixturemarker: Optional[FixtureFunctionMarker] = getattr(

test/test_n3_suite.py:35
  test/test_n3_suite.py:35: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_n3_writing will be ignored
    def test_n3_writing():

test/test_nquads_w3c.py:27
  test/test_nquads_w3c.py:27: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_nquads will be ignored
    def test_nquads(tests=None):

test/test_nt_w3c.py:29
  test/test_nt_w3c.py:29: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_nt will be ignored
    def test_nt(tests=None):

test/test_roundtrip.py:90
  test/test_roundtrip.py:90: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_cases will be ignored
    def test_cases():

test/test_roundtrip.py:107
  test/test_roundtrip.py:107: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_n3 will be ignored
    def test_n3():

test/test_sparql_agg_undef.py:26
  test/test_sparql_agg_undef.py:26: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_aggregates will be ignored
    def test_aggregates():

test/test_swap_n3.py:98
  test/test_swap_n3.py:98: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_cases will be ignored
    def test_cases():

test/test_trig_w3c.py:70
  test/test_trig_w3c.py:70: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_trig will be ignored
    def test_trig(tests=None):

test/test_turtle_w3c.py:59
  test/test_turtle_w3c.py:59: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_turtle will be ignored
    def test_turtle(tests=None):

test/jsonld/test_compaction.py:255
  test/jsonld/test_compaction.py:255: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_cases will be ignored
    def test_cases():

test/jsonld/test_localsuite.py:27
  test/jsonld/test_localsuite.py:27: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_suite will be ignored
    def test_suite():

test/jsonld/test_onedotone.py:184
  test/jsonld/test_onedotone.py:184: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_suite will be ignored
    def test_suite():

test/jsonld/test_testsuite.py:77
  test/jsonld/test_testsuite.py:77: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_suite will be ignored
    def test_suite(skip_known_bugs=True):

test/translate_algebra/test_base.py:29
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/test/translate_algebra/test_base.py:29: PytestCollectionWarning: cannot collect test class 'Test' because it has a __init__ constructor (from: test/translate_algebra/test_base.py)
    class Test:

test/translate_algebra/test_base.py:56
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/test/translate_algebra/test_base.py:56: PytestCollectionWarning: cannot collect test class 'TestExecution' because it has a __init__ constructor (from: test/translate_algebra/test_base.py)
    class TestExecution:

test/test_finalnewline.py::testFinalNewline
test/test_nt_misc.py::NTTestCase::testIssue146
test/test_nt_misc.py::NTTestCase::testIssue78
test/test_sparql.py::test_sparql_update_with_bnode_serialize_parse
test/test_sparql_parser.py::SPARQLParserTests::test_insert_large
test/test_sparql_parser.py::SPARQLParserTests::test_insert_recursionlimit
test/test_xmlliterals.py::testRoundtrip
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/plugins/serializers/nt.py:28: UserWarning: NTSerializer does not use custom encoding.
    warnings.warn("NTSerializer does not use custom encoding.")

test/test_finalnewline.py::testFinalNewline
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/plugins/serializers/jsonld.py:63: UserWarning: JSON should be encoded as unicode. Given encoding was: latin-1
    warnings.warn(

test/test_finalnewline.py::testFinalNewline
test/test_nquads.py::NQuadsParserTest::test_serialize
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/plugins/serializers/nquads.py:24: UserWarning: NQuadsSerializer does not use custom encoding.
    warnings.warn("NQuadsSerializer does not use custom encoding.")

test/test_literal.py::TestParseBoolean::testNonFalseBoolean
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/term.py:1430: UserWarning: Parsing weird boolean, 'abcd' does not map to True or False
    warnings.warn(

test/test_literal.py::TestParseBoolean::testNonFalseBoolean
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/term.py:1430: UserWarning: Parsing weird boolean, '10' does not map to True or False
    warnings.warn(

test/test_namespace.py::NamespaceTest::test_iri
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/test/test_namespace.py:44: DeprecationWarning: Please use assertTrue instead.
    self.assert_(ns["jörn"].startswith(ns))

test/test_namespace.py::NamespacePrefixTest::test_closed_namespace
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/test/test_namespace.py:213: UserWarning: DefinedNamespace does not address deprecated properties
    warn("DefinedNamespace does not address deprecated properties")

test/test_preflabel.py::TestPrefLabel::test_default_label_sorting
test/test_preflabel.py::TestPrefLabel::test_default_preflabel_sorting
test/test_preflabel.py::TestPrefLabel::test_preflabel_lang_sorting_empty_lang_attr
test/test_preflabel.py::TestPrefLabel::test_preflabel_lang_sorting_en_lang_attr
test/test_preflabel.py::TestPrefLabel::test_preflabel_lang_sorting_no_lang_attr
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/graph.py:779: DeprecationWarning: graph.preferredLabel() is deprecated and will be removed in rdflib 6.0.0.
    warn(

test/test_prettyxml.py: 10 warnings
test/test_rdfxml.py: 2 warnings
test/test_serializexml.py: 10 warnings
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/graph.py:1227: DeprecationWarning: graph.load() is deprecated, it will be removed in rdflib 6.0.0. Please use graph.parse() instead.
    warn(

test/test_rdf_lists.py::OWLCollectionTest::testCollectionRDFXML
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/plugins/serializers/rdfxml.py:262: UserWarning: Assertions on rdflib.term.BNode('Nc33941a1ba5b45e689864d24745e4a5e') other than RDF.first and RDF.rest are ignored ... including RDF.List
    self.predicate(predicate, object, depth + 1)

test/test_seq.py::SeqTestCase::testSeq
  /home/tkloczko/rpmbuild/BUILD/rdflib-6.0.0/rdflib/graph.py:929: DeprecationWarning: graph.seq() is deprecated and will be removed in rdflib 6.0.0.
    warn(

test/test_util.py::TestUtilTermConvert::test_util_from_n3_expectliteralandlangdtype
  /usr/lib64/python3.8/unittest/case.py:633: UserWarning: Code: fr is not defined in namespace XSD
    method()

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [1] test/test_dataset.py:131: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_dataset.py:78: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_dataset.py:157: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] ../../../../../usr/lib/python3.8/site-packages/_pytest/unittest.py:355: couldn't find networkx
SKIPPED [1] ../../../../../usr/lib/python3.8/site-packages/_pytest/unittest.py:355: couldn't find graph_tool
SKIPPED [1] test/test_graph.py:80: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:138: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:183: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:215: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:254: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:83: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:150: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:329: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph.py:87: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:110: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:100: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:170: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:133: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:117: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:113: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:195: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:185: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:146: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [1] test/test_graph_context.py:201: Dependencies for store 'BerkeleyDB' not available!
SKIPPED [2] ../../../../../usr/lib/python3.8/site-packages/_pytest/unittest.py:355: Known issue with newlines in text
SKIPPED [12] ../../../../../usr/lib/python3.8/site-packages/_pytest/unittest.py:153: http://localhost:3031 is unavailable.
SKIPPED [1] test/test_trig.py:121: Iterative serialization currently produces 16 copies of everything
XFAIL test/test_canonicalization.py::TestConsistency::test_consistent_ids
  reason:
XFAIL test/test_conjunctive_graph.py::test_graph_ids
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_graph_ids will be ignored
XFAIL test/test_dawg.py::test_dawg
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_dawg will be ignored
XFAIL test/test_diff.py::TestDiff::test_subsets
  reason:
XFAIL test/test_evaluate_bind.py::test_bind
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_bind will be ignored
XFAIL test/test_graph_formula.py::testFormulaStores
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - testFormulaStores will be ignored
XFAIL test/test_literal.py::TestXsdLiterals::test_make_literals_ki
  reason:
XFAIL test/test_n3_suite.py::test_n3_writing
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_n3_writing will be ignored
XFAIL test/test_namespace.py::ClosedNamespaceTest::test_repr_ef
  reason:
XFAIL test/test_nquads_w3c.py::test_nquads
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_nquads will be ignored
XFAIL test/test_nt_w3c.py::test_nt
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_nt will be ignored
XFAIL test/test_roundtrip.py::test_cases
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_cases will be ignored
XFAIL test/test_roundtrip.py::test_n3
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_n3 will be ignored
XFAIL test/test_sparql_agg_undef.py::test_aggregates
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_aggregates will be ignored
XFAIL test/test_swap_n3.py::test_cases
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_cases will be ignored
XFAIL test/test_trig_w3c.py::test_trig
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_trig will be ignored
XFAIL test/test_turtle_w3c.py::test_turtle
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_turtle will be ignored
XFAIL test/test_util.py::TestUtilTermConvert::test_util_from_n3_not_escapes_xf
  reason:
XFAIL test/jsonld/test_compaction.py::test_cases
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_cases will be ignored
XFAIL test/jsonld/test_localsuite.py::test_suite
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_suite will be ignored
XFAIL test/jsonld/test_onedotone.py::test_suite
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_suite will be ignored
XFAIL test/jsonld/test_testsuite.py::test_suite
  reason: [NOTRUN] yield tests were removed in pytest 4.0 - test_suite will be ignored
FAILED test/test_store_berkeleydb.py::BerkeleyDBTestCase::test_multigraph - ImportError: Unable to import berkeleydb, store is unusable.
FAILED test/test_store_berkeleydb.py::BerkeleyDBTestCase::test_open_shut - ImportError: Unable to import berkeleydb, store is unusable.
FAILED test/test_store_berkeleydb.py::BerkeleyDBTestCase::test_read - ImportError: Unable to import berkeleydb, store is unusable.
FAILED test/test_store_berkeleydb.py::BerkeleyDBTestCase::test_sparql_insert - ImportError: Unable to import berkeleydb, store is unusable.
FAILED test/test_store_berkeleydb.py::BerkeleyDBTestCase::test_sparql_query - ImportError: Unable to import berkeleydb, store is unusable.
FAILED test/test_store_berkeleydb.py::BerkeleyDBTestCase::test_write - ImportError: Unable to import berkeleydb, store is unusable.
============================================ 6 failed, 517 passed, 39 skipped, 7 deselected, 22 xfailed, 70 warnings in 27.47s =============================================

@westurner
Copy link
Contributor

westurner commented Jul 21, 2021 via email

@white-gecko
Copy link
Member Author

@kloczek so you say BerkeleyDB should be avoided for the future. I think this is related to #1347
So I think these tests should be skipped if the module does not exist as suggested by @westurner .

@white-gecko
Copy link
Member Author

@aucampia The goal is to move to a modern easy to maintain and easy to use test framework, so that developers use the tests and want to write tests for missing and newly introduced code.
To me, pytest appears to be that.

@kloczek
Copy link

kloczek commented Aug 22, 2021

@kloczek so you say BerkeleyDB should be avoided for the future. I think this is related to #1347
So I think these tests should be skipped if the module does not exist as suggested by @westurner .

I think that can make sense.
For example fedora is trying move away completely from libdb.
In my distribution I've manage to move away completely from gdbm and replace everything by sqlite and I'm trying to archive the same with libdb.
Argument for that is that as long as BerkeleyDB is under control of Oracle it is not well maintained.

@nicholascar
Copy link
Member

...tests should be skipped if the module does not exist...

Yes, please do allow BerkeleyDB tests to be skipped if it's not installed. We (I) want to keep BerkeleyDB as a Store option as we currently don't have any other local file system DB options. Please do feel free to complete SQLite per perhaps the started Shelve Stores though, that would be great!

@@ -535,16 +535,13 @@ def test_dawg():
setFlags()

if SPARQL10Tests:
for t in nose_tests(testers, "test/DAWG/data-r2/manifest-evaluation.ttl"):
yield t
return [t for t in nose_tests(testers, "test/DAWG/data-r2/manifest-evaluation.ttl")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these changes? It will take both time and memory to build up this list. The original could be rewritten as:

Suggested change
return [t for t in nose_tests(testers, "test/DAWG/data-r2/manifest-evaluation.ttl")]
yield from nose_tests(testers, "test/DAWG/data-r2/manifest-evaluation.ttl")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a straightforward code improvement with a generator, great!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exceptions within list comprehensions are also sometimes less optimal for debuggability, so yield probably is preferable here (though pytest has great functionality for parametrization such that each would be loop iteration is a named test) but couldn't you just change the [ ] to ( ) to return an - is it a - generator comprehension instead of building a list without a way to drop into a debugger upon exception in a named test function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different options for test IDs¶
pytest will build a string that is the test ID for each set of values in a parametrized test. These IDs can be used with -k to select specific cases to run, and they will also identify the specific case when one is failing. Running pytest with --collect-only will show the generated IDs.

Numbers, strings, booleans and None will have their usual string representation used in the test ID. For other objects, pytest will make a string based on the argument name

https://docs.pytest.org/en/latest/example/parametrize.html#different-options-for-test-ids

- python setup.py install
- flake8 --exit-zero rdflib
- PYTHONWARNINGS=default nosetests --with-timer --timer-top-n 42 --with-coverage --cover-tests --cover-package=rdflib
- coverage run -m pytest
- coverage report
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add the Python 3.10 tests in #1439 and then that failing PR can be closed.

@nicholascar
Copy link
Member

@ashleysommer @white-gecko @edmondchuc @aucampia @westurner @cclauss @FlorianLudwig @rchateauneu

It seems our biggest rdflib issues now are to do with our testing framework, automated testing and automated style/language and other tests to enhance consistency. The small mess here is preventing us from moving to support Python 3.10 and a number of other things.

If you are keen to assist with rdflib development in the short term, please could you all prioritize this PR to remove nose, implement pytest and then configure Drone to work with pytest for all Python versions?

If we can get this done, we will likely then be able to develop new features much more easily. Thanks.

@aucampia
Copy link
Member

@nicholascar I will focus my efforts here until it is done.

I am not sure what the best way is to proceed, I think one option is to make PRs against @white-gecko 's branch, otherwise I can make a new branch continuing from this one and add additional changes needed.

It would be nice if we could find some way of doing this incrementally but I am unsure what options there are for that and will look into it.

@nicholascar
Copy link
Member

@aucampia perhaps if we move this branch to an rdflib branch, i.e. not a branch on @white-gecko's fork, then it will be easier to raise PR against that?

@white-gecko, can you please move this to an rdflib branch? Also, you might like to rebase now that #1267's merged, as you indicated in the description.

@aucampia
Copy link
Member

aucampia commented Oct 18, 2021

The drop in coverage seems to be at least partly related to manifest testing. With pytest basically none of those were running, and I remember now why I made this comment about subtests earlier on. I changed manifest testing to use pytest_subtest now and this seems to work. I think there are other options with pytest that pytest-subtest, but they require restructuring tests significantly as far as I know. I will try make it work at least with subtest and then we can consider what to do from there on.

There are also still a couple of places where nose is referenced directly.

Coverage after that change: https://coveralls.io/jobs/88589568

@nicholascar
Copy link
Member

OK, I'm happy to pick up and review a whole pile of test in detail too. I'll work out which set - parsers or serialisers or stores etc. and ensure I know how many tests there actually are there, what proportion are operating and what the nose/pytest differences are.

@aucampia
Copy link
Member

I have thought more about manifest tests, and there is another way to do them than with pytest-subtests, and I will make make some as an example.

However, I can't really think of a very clean way to integrate either way with what is happening inside if __name__ == "__main__": of test_dawg.py.

rdflib/test/test_dawg.py

Lines 535 to 637 in d9e86c9

if __name__ == "__main__":
import sys
import time
start = time.time()
if len(sys.argv) > 1:
NAME = sys.argv[1]
DEBUG_FAIL = True
i = 0
success = 0
skip = 0
for _type, t in test_dawg():
if NAME and not str(t[0]).startswith(NAME):
continue
i += 1
try:
_type(t)
add_test(t[0], "passed")
success += 1
except SkipTest as e:
msg = skiptests.get(t[0], e.args)
add_test(t[0], "untested", msg)
print("skipping %s - %s" % (t[0], msg))
skip += 1
except KeyboardInterrupt:
raise
except AssertionError:
add_test(t[0], "failed")
except:
add_test(t[0], "failed", "error")
import traceback
traceback.print_exc()
sys.stderr.write("%s\n" % t[0])
print("\n----------------------------------------------------\n")
print("Failed tests:")
for failed in failed_tests:
print(failed)
print("\n----------------------------------------------------\n")
print("Error tests:")
for error in error_tests:
print(error)
print("\n----------------------------------------------------\n")
print("Most common fails:")
for failed in fails.most_common(10):
failed_str = str(failed)
print(failed_str[:450] + (failed_str[450:] and "..."))
print("\n----------------------------------------------------\n")
if errors:
print("Most common errors:")
for error in errors.most_common(10):
print(error)
else:
print("(no errors!)")
f_sum = sum(fails.values())
e_sum = sum(errors.values())
if success + f_sum + e_sum + skip != i:
print("(Something is wrong, %d!=%d)" % (success + f_sum + e_sum + skip, i))
print(
"\n%d tests, %d passed, %d failed, %d errors, \
%d skipped (%.2f%% success)"
% (i, success, f_sum, e_sum, skip, 100.0 * success / i)
)
print("Took %.2fs" % (time.time() - start))
if not NAME:
now = isodate.datetime_isoformat(datetime.datetime.utcnow())
with open("testruns.txt", "a") as tf:
tf.write(
"%s\n%d tests, %d passed, %d failed, %d errors, %d "
"skipped (%.2f%% success)\n\n"
% (now, i, success, f_sum, e_sum, skip, 100.0 * success / i)
)
earl_report = os.path.join(
TEST_DIR, "../test_reports/rdflib_sparql-%s.ttl" % now.replace(":", "")
)
report.serialize(earl_report, format="n3")
report.serialize(
os.path.join(TEST_DIR, "../test_reports/rdflib_sparql-latest.ttl"),
format="n3",
)
print("Wrote EARL-report to '%s'" % earl_report)

I think the best approach is to just scrap that (and other similar code) for now. I'm not sure if something is relying on it. I think it would be nice if there was a test manifest executor that can be run outside of pytest, which is essentially what is happening there as far as I can tell, but maybe this can be done in a way that is more generic and can be reused in other places. Not sure if we should do that now however, possibly it's best to just get rid of that for now.

@aucampia
Copy link
Member

Actually, I guess we do want to be able to write earl reports still. So i will look at running tests manifests outside of pytest to generate this, but maybe not with highest priority. But any ideas here will be welcome.

@aucampia
Copy link
Member

I see there is nose_tst_earl_report, will try and make something similar without nose.

@nicholascar
Copy link
Member

Most of the earl test reports haven’t been regenerated for a very, very, long time! It would be good to regenerate them. Even if the Working Groups (RDF etc) that they were originally for aren’t around any more. We might consider putting the results up somewhere in a form other than RDF to show off RDFLib’s results against those tests.

@nicholascar
Copy link
Member

I don’t think anything is relying on the test files’ __main__ functions.if something is, it shouldn’t be!

Yes, convert nose_tst_earl_report to just earl_report.

I guess part of all of this is to find out what all these testutils.py and manifest.py are all doing…

@aucampia
Copy link
Member

thanks for the notes @westurner - will have a look at pytest plugins, it may make the most sense

@aucampia
Copy link
Member

aucampia commented Oct 19, 2021

Hitting some failures with rdflib.compare.isomorphic on drone which I can't reproduce locally: https://drone.rdflib.ashs.dev/RDFLib/rdflib/520/1/2

Update 1:

Seems to be somewhat state dependent, if I just run the two failing test I don't get problems.

@westurner
Copy link
Contributor

westurner commented Oct 19, 2021 via email

@aucampia
Copy link
Member

aucampia commented Oct 19, 2021

Actually I think it is related ALLOW_LISTS_OF_LISTS here:

@pytest.fixture(scope="module", autouse=True)
def testsuide_dir():
default_allow = rdflib.plugins.parsers.jsonld.ALLOW_LISTS_OF_LISTS
rdflib.plugins.parsers.jsonld.ALLOW_LISTS_OF_LISTS = allow_lists_of_lists
old_cwd = getcwd()
chdir(test_dir)
yield
rdflib.plugins.parsers.jsonld.ALLOW_LISTS_OF_LISTS = default_allow
chdir(old_cwd)

But I'm still figuring it out.

@westurner
Copy link
Contributor

westurner commented Oct 19, 2021 via email

@aucampia
Copy link
Member

Okay all good, there were a couple of places where global state was not cleaned up after modifying it, but now it seems fine. Coverage is now up to 78.3% https://coveralls.io/builds/43624040 - still 4 percentage points lower than master.

@aucampia
Copy link
Member

I found some more "yield" tests ( https://coveralls.io/builds/43624298 ) but now I'm at a bit of a loss of where the remaining coverage has went to. Will compare the module level coverage later to see.

@aucampia
Copy link
Member

Actually I think the remaining coverage is doctests, will see what to do about that.

@aucampia
Copy link
Member

aucampia commented Oct 20, 2021

Was doctest run on rst files also? I tried now but it seems to not work well:

__________________________________________________________________________ [doctest] rdf_terms.rst __________________________________________________________________________
080 .. __: http://en.wikipedia.org/wiki/Blank_node
081 
082 .. autoclass:: rdflib.term.BNode
083     :noindex:
084 
085 .. code-block:: python
086 
087     >>> from rdflib import BNode
088     >>> bn = BNode()
089     >>> bn
Expected:
    rdflib.term.BNode('AFwALAKU0')
Got:
    rdflib.term.BNode('N314f863d3521475aab9a70f782f5a8d7')

/home/iwana/sw/d/github.com/iafork/rdflib/docs/rdf_terms.rst:89: DocTestFailure

Can of course be fixed, but just wondering if it was working before. If not we can defer doing it till later.

Update 1:

Command was:

.venv/bin/pytest -x --doctest-modules --doctest-glob="*.rst" docs/ 

@aucampia
Copy link
Member

aucampia commented Oct 20, 2021

Okay coverage is back to where it was before (even slightly higher):

I suspect it is because some things were ignored with nosetest that are not ignored with pytest:

nosetest ignored:

exclude=rdflib.plugins.sparql.paths|rdflib.extras.external_graph_libs

pytest ignores:

https://github.com/iafork/rdflib/blob/ad795edb92a84c8b40a8ab23469d38517c8f2a6b/setup.cfg#L34-L37

   --ignore=test/translate_algebra
   --ignore=admin
   --ignore=rdflib/extras/external_graph_libs.py
   --ignore-glob=docs/*.py

@aucampia
Copy link
Member

I think mostly what is left now is to fix up reporting.

@aucampia
Copy link
Member

Did json earl reporting work on master? I tried running it but it does not work for me:

$ .venv/bin/python -m test.jsonld.test_testsuite
Traceback (most recent call last):
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/rdflib/plugins/parsers/nquads.py", line 72, in parse
    self.parseline(bnode_context)
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/rdflib/plugins/parsers/nquads.py", line 86, in parseline
    predicate = self.predicate()
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/rdflib/plugins/parsers/ntriples.py", line 241, in predicate
    raise ParseError("Predicate must be uriref")
rdflib.exceptions.ParserError: Predicate must be uriref

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/test/jsonld/test_testsuite.py", line 148, in <module>
    args[0](*args[1:])
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/test/jsonld/runner.py", line 64, in do_test_parser
    expected_graph = _load_nquads(expectedpath)
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/test/jsonld/runner.py", line 113, in _load_nquads
    graph.parse(data=data, format="nquads")
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/rdflib/graph.py", line 1749, in parse
    context.parse(source, publicID=publicID, format=format, **args)
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/rdflib/graph.py", line 1252, in parse
    parser.parse(source, self, **args)
  File "/home/iwana/d.x/github.com/RDFLib/rdflib/rdflib/plugins/parsers/nquads.py", line 74, in parse
    raise ParseError("Invalid line (%s):\n%r" % (msg, __line))
rdflib.exceptions.ParserError: Invalid line (Predicate must be uriref):
'_:term _:term "plain value" .'

I suspect I just don't know how to run it. I would like to reproduce it as closely as possible.

@nicholascar
Copy link
Member

Did json earl reporting work on master?

I think it's not been run for a very long time so the answer is effectively no but, as you say, a probable yes if looked in to.

@aucampia
Copy link
Member

I will try finish the reporting and publish #1452 this weekend

@nicholascar
Copy link
Member

I will try finish the reporting and publish #1452 this weekend

Fantastic work @aucampia! I and many others really appreciate your work here.

@aucampia
Copy link
Member

aucampia commented Oct 24, 2021

I now have EARL reports working, details can be found in https://github.com/iafork/rdflib/blob/6f6ffa199ee0ebadd1225fefbe524707c1ddc0ac/test/README.rst. It is done with a pytest plugin, and when the plugin is enabled it will create an EARL assertion for every test with a rdf_test_uri parameter. The plugin is however also in the test directory, and I think it's best to keep it there for now before making it an official thing provided by RDFLib.

There is still some final touches needed.

  • I still need to do something about run_test.py, run_tests.sh and run_tests_with_coverage_report.sh. I'm thinking of deleting the two *.sh files and just fixing run_test.py up.
  • I need to fix the README
  • maybe some other things?

@aucampia
Copy link
Member

There is also some warning relating to the EARL reporting plugin which I can't quite make sense of:

$ pytest \
>    --earl-asserter-uri=http://example.com \
>    --earl-asserter-name 'Example Name' \
>    --earl-report=/var/tmp/earl/earl-trig.ttl \
>    test/test_trig_w3c.py
============================================================================ test session starts ============================================================================
platform linux -- Python 3.7.12, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/iwana/sw/d/github.com/iafork/rdflib, configfile: setup.cfg
plugins: subtests-0.5.0, cov-3.0.0, reportlog-0.1.2
collected 335 items                                                                                                                                                         

test/test_trig_w3c.py ............................................................................................................................................... [ 42%]
..................................................................................................................................................................... [ 91%]
...........................                                                                                                                                           [100%]

============================================================================= warnings summary ==============================================================================
.venv/lib64/python3.7/site-packages/_pytest/config/__init__.py:676
  /home/iwana/sw/d/github.com/iafork/rdflib/.venv/lib64/python3.7/site-packages/_pytest/config/__init__.py:676: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: test.earl
    self.import_plugin(import_spec)

rdflib/graph.py:1270
  /home/iwana/sw/d/github.com/iafork/rdflib/rdflib/graph.py:1270: DeprecationWarning: graph.load() is deprecated, it will be removed in rdflib 6.0.0. Please use graph.parse() instead.
    "graph.load() is deprecated, it will be removed in rdflib 6.0.0. "

-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================================================================== 335 passed, 2 warnings in 0.95s ======================================================================
.venv/lib64/python3.7/site-packages/_pytest/config/__init__.py:676
  /home/iwana/sw/d/github.com/iafork/rdflib/.venv/lib64/python3.7/site-packages/_pytest/config/__init__.py:676: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: test.earl
    self.import_plugin(import_spec)

@aucampia
Copy link
Member

Example reports can be found here: https://filebin.net/w8kplw7c0tdr6c07

@westurner
Copy link
Contributor

"JSON-LD 1.1 Processor Conformance
EARL results from the JSON-LD 1.1 Test Suite"
https://w3c.github.io/json-ld-api/reports/

  • Table of Contents
  • tabular html aggregation of EARL reports
    • rdflib-jsonld

https://w3c.github.io/json-ld-streaming/reports/

  • DOC: is the title wrong on this HTML report?

@aucampia
Copy link
Member

@westurner thanks, I did compare the pytest EALR outputs to the reports listed for w3c:

For jsonld 1.0:

For jsonld 1.1

One obvious difference is that we are running significantly fewer tests, but it's the same for master and the pytest branch:

$ pytest ./test/jsonld/test_onedotone.py
============================================================================ test session starts ============================================================================
platform linux -- Python 3.7.12, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/iwana/sw/d/github.com/iafork/rdflib, configfile: setup.cfg
plugins: subtests-0.5.0, cov-3.0.0, reportlog-0.1.2
collected 262 items                                                                                                                                                         

test/jsonld/test_onedotone.py ....................................................................................................................................... [ 51%]
...............................................................................................................................                                       [100%]

============================================================================= warnings summary ==============================================================================
.venv/lib64/python3.7/site-packages/_pytest/config/__init__.py:676
  /home/iwana/sw/d/github.com/iafork/rdflib/.venv/lib64/python3.7/site-packages/_pytest/config/__init__.py:676: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: test.earl
    self.import_plugin(import_spec)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================================================================== 262 passed, 1 warning in 0.87s =======================================================================
$ .venv/bin/python run_tests.py ./test/jsonld/test_onedotone.py 
Running nose with: ./test/jsonld/test_onedotone.py --attr= --where=./ --with-doctest --doctest-extension=.doctest --doctest-tests
......................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 262 tests in 0.607s

OK

This should probably be looked into, but can be done later.

@aucampia
Copy link
Member

#1452 is ready for review, will continue discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants