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

fix: reference to global inside get_target_namespace_elements #2311

Merged
merged 1 commit into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rdflib/tools/defined_namespace_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_target_namespace_elements(
for e in elements:
desc = e[1].replace("\n", " ")
elements_strs.append(
f" {e[0].replace(args.target_namespace, '')}: URIRef # {desc}\n"
f" {e[0].replace(target_namespace, '')}: URIRef # {desc}\n"
)

return elements, elements_strs
Expand Down
15 changes: 15 additions & 0 deletions test/test_namespace/test_definednamespace_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import sys
from pathlib import Path

from rdflib.graph import Graph
from rdflib.tools.defined_namespace_creator import get_target_namespace_elements


def test_definednamespace_creator_qb():
"""
Expand Down Expand Up @@ -163,3 +166,15 @@ def test_definednamespace_creator_multiple_comments():

# cleanup
Path.unlink(Path("_MULTILINESTRINGEXAMPLE.py"))


def test_get_target_namespace_elements(rdfs_graph: Graph) -> None:
elements = get_target_namespace_elements(
rdfs_graph, "http://www.w3.org/2000/01/rdf-schema#"
)
assert 2 == len(elements)
assert 16 == len(elements[0])
assert (
"http://www.w3.org/2000/01/rdf-schema#Class",
"The class of classes.",
) in elements[0]