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

Tests are not running: E AttributeError: can't set attribute #12

Open
georghildebrand opened this issue Dec 1, 2021 · 3 comments
Open
Labels
bug Something isn't working

Comments

@georghildebrand
Copy link

Hi guys, thanks for working on this. RDFLib is great!

To Reproduce
Follow install instructions (install requirements etc)

Run tests python -m pytest tests

Expected behavior
Tests should pass

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS, pvenv, python 3.9

`============================= test session starts ==============================
platform darwin -- Python 3.9.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /workdir/RDFLib/rdflib-hdt
collected 29 items / 2 errors / 27 selected

==================================== ERRORS ====================================
___________________ ERROR collecting tests/hdt_store_test.py ___________________
tests/hdt_store_test.py:4: in
from rdflib_hdt import HDTStore, optimize_sparql
rdflib_hdt/init.py:12: in
from rdflib_hdt.sparql_op import optimize_sparql
rdflib_hdt/sparql_op.py:6: in
import rdflib.plugins.sparql.evaluate as sparql_evaluate
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/init.py:35: in
from . import parser
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/parser.py:182: in
Param('prefix', PN_PREFIX)) + Suppress(':').leaveWhitespace()
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/parserutils.py:113: in init
self.name = name
E AttributeError: can't set attribute
___________________ ERROR collecting tests/wrappers_test.py ____________________
tests/wrappers_test.py:3: in
from rdflib_hdt import HDTDocument
rdflib_hdt/init.py:12: in
from rdflib_hdt.sparql_op import optimize_sparql
rdflib_hdt/sparql_op.py:6: in
import rdflib.plugins.sparql.evaluate as sparql_evaluate
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/init.py:35: in
from . import parser
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/parser.py:182: in
Param('prefix', PN_PREFIX)) + Suppress(':').leaveWhitespace()
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/parserutils.py:113: in init
self.name = name
E AttributeError: can't set attribute
=============================== warnings summary ===============================
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/compat.py:8
pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/compat.py:8
/workdir/RDFLib/rdflib-hdt/pyhdt_venv/lib/python3.9/site-packages/rdflib/plugins/sparql/compat.py:8: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
from collections import Mapping, MutableMapping # was added in 2.6

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
ERROR tests/hdt_store_test.py - AttributeError: can't set attribute
ERROR tests/wrappers_test.py - AttributeError: can't set attribute
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!`

@Callidon
Copy link
Collaborator

Callidon commented Dec 1, 2021

Hi 👋 It seems to be an issue with rdflib itself, because according to the stacktrace you posted, its the line import rdflib.plugins.sparql.evaluate as sparql_evaluate which fails.
Could to try to run this import statement in a separated python file with no rdflib_hdt import and see if the issue remains? if so, then I think you should report the issue to the rdflib project directly.

@Callidon Callidon added the bug Something isn't working label Dec 1, 2021
@georghildebrand
Copy link
Author

@Callidon ack, that import is producing the error. I will open an Issue there. Thx for your fast feedback.

@georghildebrand
Copy link
Author

@Callidon I just realized that the issue seems to be related to the version of rdflib when cloning and running the import in the latest:6.0.2

python -c "import rdflib.plugins.sparql.evaluate as sparql_evaluate"

Works fine

However, when using 6.0.2 next issue comes up with 'rdflib-hdt' but this time the test of an SPARQL fails it seems...

`============================= test session starts ==============================
platform darwin -- Python 3.9.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /workdir/RDFLib/rdflib-hdt
collected 61 items

tests/hdt_document_test.py ........... [ 18%]
tests/hdt_iterators_test.py ................ [ 44%]
tests/hdt_store_test.py ..............................F [ 95%]
tests/join_iterator_test.py .. [ 98%]
tests/wrappers_test.py . [100%]

=================================== FAILURES ===================================
___________________________ test_rdflib_sparql_query ___________________________

def test_rdflib_sparql_query():
    optimize_sparql()
    graph = Graph(store=store)
    sparql_query = """
    PREFIX ex: <http://example.org/>
    SELECT * WHERE {
        ?s ex:p1 ?o
    }
    """
  qres = graph.query(sparql_query)

tests/hdt_store_test.py:80:


pyhdt_venv/lib/python3.9/site-packages/rdflib/graph.py:1301: in query
initNs = initNs or dict(self.namespaces())
pyhdt_venv/lib/python3.9/site-packages/rdflib/graph.py:1004: in namespaces
for prefix, namespace in self.namespace_manager.namespaces():
pyhdt_venv/lib/python3.9/site-packages/rdflib/graph.py:347: in _get_namespace_manager
self.__namespace_manager = NamespaceManager(self)
pyhdt_venv/lib/python3.9/site-packages/rdflib/namespace/init.py:334: in init
for p, n in self.namespaces(): # self.bind is not always called


self = <rdflib.namespace.NamespaceManager object at 0x108d99490>

def namespaces(self):
  for prefix, namespace in self.store.namespaces():

E TypeError: 'NoneType' object is not iterable

pyhdt_venv/lib/python3.9/site-packages/rdflib/namespace/init.py:559: TypeError
=========================== short test summary info ============================
FAILED tests/hdt_store_test.py::test_rdflib_sparql_query - TypeError: 'NoneTy...`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants