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 for issue1769 #1771

Merged
merged 5 commits into from Apr 3, 2022
Merged

Fix for issue1769 #1771

merged 5 commits into from Apr 3, 2022

Conversation

ghost
Copy link

@ghost ghost commented Mar 23, 2022

Summary of changes

Fix for issue #1769, suggested extension of from_n3 to handle “numeric shortcut” strings containing (otherwise valid) characters that cause isdigit to return False, add test illustrating previously-failing examples.

Or continue with the current “fail-safe” approach, reject this PR, resolve issue #1769 as “wontfix” and explicitly note the use of isdigit in the documentation along with the implications for numeric shortcut strings containing negative numbers and scientific notation --- the non-shortcut representation (e.g. '"-5"^^xsd:integer') is properly handled:

assert rdflib.util.from_n3('"-5"^^xsd:integer') == rdflib.term.Literal(
    '-5', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Added tests for any changes that have a runtime impact.
  • Checked that all tests and type checking passes. (but see ¹)
  • For changes that have a potential impact on users of this project:
    • Updated relevant documentation to avoid inaccuracies.
    • Considered adding additional documentation.
    • Considered adding an example in ./examples for new features.
    • Considered updating our changelog (CHANGELOG.md).
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

¹

$ mypy rdflib/util.py 
rdflib/term.py:1909: error: Item "Element" of "Union[Document, Element]" has no attribute "attributes"
rdflib/term.py:1914: error: Item "Element" of "Union[Document, Element]" has no attribute "attributes"
Found 2 errors in 1 file (checked 1 source file)

@aucampia
Copy link
Member

aucampia commented Mar 27, 2022

I'm somewhat hesitant to maintain rdflib.util.from_n3 as it is not used in actual parsing and has issues that are not present in actual parsers (see #1778), so I would prefer we deprecate it and rather advise people to use the real parsers.

However if we do plan to keep it we should fix it so it does work for n3 as it's name suggests, I would prefer we somehow hook into the actual n3 parser, but otherwise any fix that makes it more conformant is good.

Copy link
Member

@nicholascar nicholascar left a comment

Choose a reason for hiding this comment

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

Fine other than my one style only change request in a comment

@aucampia
Copy link
Member

aucampia commented Apr 2, 2022

@gjhiggins would you be okay if I integrate the tests here into https://github.com/RDFLib/rdflib/blob/8a309774665182df135be9f2707303571764320a/test/test_parsers/test_parser_turtlelike.py ?

Would prefer that as they should pass for many formats, and we likely have many other tests we want to perform on both from_n3 and on the other formats.

@ghost
Copy link
Author

ghost commented Apr 2, 2022

@gjhiggins would you be okay if I integrate the tests here into https://github.com/RDFLib/rdflib/blob/8a309774665182df135be9f2707303571764320a/test/test_parsers/test_parser_turtlelike.py ?

Oh, absolutely. I have zero sense of "ownership" - except perhaps for stuff other people wouldn't touch with a bargepole 😄 but thanks for asking.

Would prefer that as they should pass for many formats, and we likely have many other tests we want to perform on both from_n3 and on the other formats.

There's more to come in the general context of the test matrices area w.r.t. the dataset rework, I've been handling it thusly:

example2_root = os.path.join(
    CONSISTENT_DATA_DIR, "example-2-default-and-two-named-graphs."
)

@pytest.fixture
def example2(request):
    d = Dataset()
    d.bind("ex", Namespace("http://example.org/"))

    alice = BNode()  # Alice
    bob = BNode()  # Bob

    alice_graph = d.graph(alice_uri)
    bob_graph = d.graph(bob_uri)

    d.add((alice_uri, DCTERMS.publisher, Literal("Alice")))
    d.add((bob_uri, DCTERMS.publisher, Literal("Bob")))

    alice_graph.add((alice, FOAF.mbox, URIRef("mailto:alice@work.example.org")))
    alice_graph.add((alice, FOAF.name, Literal("Alice")))

    bob_graph.add((bob, FOAF.name, Literal("Bob")))
    bob_graph.add((bob, FOAF.mbox, URIRef("mailto:bob@oldcorp.example.org")))
    bob_graph.add((bob, FOAF.knows, alice))

    yield d, alice_graph, bob_graph

context_formats = [
    "json-ld",
    "trix",
    "nquads",
    "trig",
    "hext",
]

@pytest.fixture
def xfail_selected_context_parse_data_formats(request):
    fmt = request.getfixturevalue("fmt")
    expected_failures = [
        # "json-ld",
        # "trix",
        # "nquads",
        # "trig",
        # "hext",
    ]
    if fmt in expected_failures:
        request.node.add_marker(
            pytest.mark.xfail(reason=f"Expected failure with {fmt}")
        )

@pytest.mark.parametrize("fmt", context_formats)
@pytest.mark.usefixtures("xfail_selected_context_parse_data_formats")
def test_parse_example2_from_data(fmt, example2):
    # Use programmatically-created graphs as standard to be checked against
    d1, alice_graph, bob_graph = example2

    d2 = Dataset()
    d2.bind("ex", Namespace("http://example.org/"))
    with open(example2_root + fmt, "r") as fp:
        d2.parse(data=fp.read(), format=fmt)

    assert len(list(d2.contexts())) == 2
    assert len(list(d2.graphs())) == 2
    assert len(d2) == 2
    assert alice_uri in d2.contexts()
    assert bob_uri in d2.contexts()
    assert len(list(d1.quads((None, None, None, None)))) == len(
        list(d2.quads((None, None, None, None)))
    )
    assert len(d1.store) == len(d2.store)
    assert isomorphic(d1, d2)

Also refactor as per suggestion from @nicholascar
@aucampia
Copy link
Member

aucampia commented Apr 2, 2022

Tests are moved now, and I added a bunch more tests, including two xfail tests for from_n3. I also applied @nicholascar 's suggestion.

Output:

$ .venv/bin/python3 -m pytest test/test_parsers/test_parser_turtlelike.py -rA -v
============================================================================ test session starts ============================================================================
platform linux -- Python 3.9.12, pytest-7.1.1, pluggy-1.0.0 -- /home/iwana/sw/d/github.com/iafork/rdflib.cleanish/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/iwana/sw/d/github.com/iafork/rdflib.cleanish, configfile: tox.ini
plugins: subtests-0.7.0, cov-3.0.0, md-report-0.2.0
collected 212 items                                                                                                                                                         

test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples--5-"-5"^^<http://www.w3.org/2001/XMLSchema#integer>-parse_identifier] PASSED                      [  0%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads--5-"-5"^^<http://www.w3.org/2001/XMLSchema#integer>-parse_identifier] PASSED                        [  0%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--5-"-5"^^<http://www.w3.org/2001/XMLSchema#integer>-parse_identifier] PASSED                        [  1%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--5--5-parse_identifier] PASSED                                                                      [  1%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--5-"-5"^^<http://www.w3.org/2001/XMLSchema#integer>-parse_identifier] PASSED                          [  2%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--5--5-parse_identifier] PASSED                                                                        [  2%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5-"-5"^^<http://www.w3.org/2001/XMLSchema#integer>-parse_identifier] PASSED                            [  3%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5-"-5"^^<http://www.w3.org/2001/XMLSchema#integer>-parse_n3_identifier] PASSED                         [  3%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5--5-parse_identifier] PASSED                                                                          [  4%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5--5-parse_n3_identifier] PASSED                                                                       [  4%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples--5.0-"-5.0"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                  [  5%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads--5.0-"-5.0"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                    [  5%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--5.0-"-5.0"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                    [  6%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--5.0--5.0-parse_identifier] PASSED                                                                  [  6%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--5.0-"-5.0"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                      [  7%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--5.0--5.0-parse_identifier] PASSED                                                                    [  7%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.0-"-5.0"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                        [  8%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.0-"-5.0"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_n3_identifier] PASSED                     [  8%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.0--5.0-parse_identifier] PASSED                                                                      [  8%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.0--5.0-parse_n3_identifier] PASSED                                                                   [  9%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples--5.5-"-5.5"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                  [  9%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads--5.5-"-5.5"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                    [ 10%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--5.5-"-5.5"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                    [ 10%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--5.5--5.5-parse_identifier] PASSED                                                                  [ 11%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--5.5-"-5.5"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                      [ 11%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--5.5--5.5-parse_identifier] PASSED                                                                    [ 12%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.5-"-5.5"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_identifier] PASSED                        [ 12%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.5-"-5.5"^^<http://www.w3.org/2001/XMLSchema#decimal>-parse_n3_identifier] PASSED                     [ 13%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.5--5.5-parse_identifier] PASSED                                                                      [ 13%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--5.5--5.5-parse_n3_identifier] PASSED                                                                   [ 14%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-4200000000.0-"4.2E9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED          [ 14%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-4200000000.0-"4.2e9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED          [ 15%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-4200000000.0-"4.2E9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 15%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-4200000000.0-"4.2e9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 16%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-4200000000.0-"4.2E9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 16%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-4200000000.0-"4.2e9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 16%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-4200000000.0-4.2E9-parse_identifier] PASSED                                                         [ 17%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-4200000000.0-4.2e9-parse_identifier] PASSED                                                         [ 17%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-4200000000.0-"4.2E9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 18%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-4200000000.0-"4.2e9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 18%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-4200000000.0-4.2E9-parse_identifier] PASSED                                                           [ 19%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-4200000000.0-4.2e9-parse_identifier] PASSED                                                           [ 19%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-"4.2E9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                [ 20%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-"4.2E9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_n3_identifier] PASSED             [ 20%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-"4.2e9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                [ 21%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-"4.2e9"^^<http://www.w3.org/2001/XMLSchema#double>-parse_n3_identifier] PASSED             [ 21%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-4.2E9-parse_identifier] PASSED                                                             [ 22%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-4.2E9-parse_n3_identifier] PASSED                                                          [ 22%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-4.2e9-parse_identifier] PASSED                                                             [ 23%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-4200000000.0-4.2e9-parse_n3_identifier] PASSED                                                          [ 23%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-1.23e-07-"1.23E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 24%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-1.23e-07-"1.23e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 24%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-1.23e-07-"1.23E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 25%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-1.23e-07-"1.23e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 25%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-1.23e-07-"1.23E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 25%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-1.23e-07-"1.23e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 26%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-1.23e-07-1.23E-7-parse_identifier] PASSED                                                           [ 26%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-1.23e-07-1.23e-7-parse_identifier] PASSED                                                           [ 27%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-1.23e-07-"1.23E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                [ 27%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-1.23e-07-"1.23e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                [ 28%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-1.23e-07-1.23E-7-parse_identifier] PASSED                                                             [ 28%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-1.23e-07-1.23e-7-parse_identifier] PASSED                                                             [ 29%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-"1.23E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                  [ 29%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-"1.23E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_n3_identifier] PASSED               [ 30%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-"1.23e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                  [ 30%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-"1.23e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_n3_identifier] PASSED               [ 31%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-1.23E-7-parse_identifier] PASSED                                                               [ 31%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-1.23E-7-parse_n3_identifier] PASSED                                                            [ 32%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-1.23e-7-parse_identifier] PASSED                                                               [ 32%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-1.23e-07-1.23e-7-parse_n3_identifier] PASSED                                                            [ 33%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples--4.1e-07-"-4.1E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 33%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples--4.1e-07-"-4.1e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED            [ 33%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads--4.1e-07-"-4.1E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 34%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads--4.1e-07-"-4.1e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 34%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--4.1e-07-"-4.1E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 35%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--4.1e-07-"-4.1e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED              [ 35%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--4.1e-07--4.1E-7-parse_identifier] PASSED                                                           [ 36%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle--4.1e-07--4.1e-7-parse_identifier] PASSED                                                           [ 36%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--4.1e-07-"-4.1E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                [ 37%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--4.1e-07-"-4.1e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                [ 37%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--4.1e-07--4.1E-7-parse_identifier] PASSED                                                             [ 38%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig--4.1e-07--4.1e-7-parse_identifier] PASSED                                                             [ 38%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07-"-4.1E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                  [ 39%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07-"-4.1E-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_n3_identifier] PASSED               [ 39%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07-"-4.1e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_identifier] PASSED                  [ 40%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07-"-4.1e-7"^^<http://www.w3.org/2001/XMLSchema#double>-parse_n3_identifier] PASSED               [ 40%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07--4.1E-7-parse_identifier] PASSED                                                               [ 41%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07--4.1E-7-parse_n3_identifier] XFAIL (bug in from_n3)                                            [ 41%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07--4.1e-7-parse_identifier] PASSED                                                               [ 41%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3--4.1e-07--4.1e-7-parse_n3_identifier] XFAIL (bug in from_n3)                                            [ 42%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-false-"false"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier] PASSED                [ 42%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-false-"false"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier] PASSED                  [ 43%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-false-"false"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier] PASSED                  [ 43%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-false-false-parse_identifier] PASSED                                                                [ 44%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-false-"false"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier] PASSED                    [ 44%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-false-false-parse_identifier] PASSED                                                                  [ 45%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-false-"false"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier] PASSED                      [ 45%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-false-"false"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_n3_identifier] PASSED                   [ 46%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-false-false-parse_identifier] PASSED                                                                    [ 46%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-false-false-parse_n3_identifier] PASSED                                                                 [ 47%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier0] PASSED                 [ 47%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier0] PASSED                   [ 48%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier0] PASSED                   [ 48%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-true-true-parse_identifier0] PASSED                                                                 [ 49%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier0] PASSED                     [ 49%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-true-true-parse_identifier0] PASSED                                                                   [ 50%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier0] PASSED                       [ 50%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_n3_identifier0] PASSED                    [ 50%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-true-parse_identifier0] PASSED                                                                     [ 51%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-true-parse_n3_identifier0] PASSED                                                                  [ 51%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier1] PASSED                 [ 52%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier1] PASSED                   [ 52%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier1] PASSED                   [ 53%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-true-true-parse_identifier1] PASSED                                                                 [ 53%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier1] PASSED                     [ 54%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-true-true-parse_identifier1] PASSED                                                                   [ 54%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_identifier1] PASSED                       [ 55%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-"true"^^<http://www.w3.org/2001/XMLSchema#boolean>-parse_n3_identifier1] PASSED                    [ 55%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-true-parse_identifier1] PASSED                                                                     [ 56%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-true-true-parse_n3_identifier1] PASSED                                                                  [ 56%]
test/test_parsers/test_parser_turtlelike.py::test_literals[ntriples-example-"example"-parse_identifier] PASSED                                                        [ 57%]
test/test_parsers/test_parser_turtlelike.py::test_literals[nquads-example-"example"-parse_identifier] PASSED                                                          [ 57%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-example-"example"-parse_identifier] PASSED                                                          [ 58%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-example-'example'-parse_identifier] PASSED                                                          [ 58%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-example-'''example'''-parse_identifier] PASSED                                                      [ 58%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-example-"""example"""-parse_identifier] PASSED                                                      [ 59%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-example-"example"-parse_identifier] PASSED                                                            [ 59%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-example-'example'-parse_identifier] PASSED                                                            [ 60%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-example-'''example'''-parse_identifier] PASSED                                                        [ 60%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-example-"""example"""-parse_identifier] PASSED                                                        [ 61%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-example-"example"-parse_identifier] PASSED                                                              [ 61%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-example-"example"-parse_n3_identifier] PASSED                                                           [ 62%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \t suffix-"prefix \\t suffix"-parse_identifier] PASSED                                       [ 62%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \t suffix-'prefix \\t suffix'-parse_identifier] PASSED                                       [ 63%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \t suffix-'''prefix \\t suffix'''-parse_identifier] PASSED                                   [ 63%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \t suffix-"""prefix \\t suffix"""-parse_identifier] PASSED                                   [ 64%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \t suffix-"prefix \\t suffix"-parse_identifier] PASSED                                         [ 64%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \t suffix-'prefix \\t suffix'-parse_identifier] PASSED                                         [ 65%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \t suffix-'''prefix \\t suffix'''-parse_identifier] PASSED                                     [ 65%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \t suffix-"""prefix \\t suffix"""-parse_identifier] PASSED                                     [ 66%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \t suffix-"prefix \\t suffix"-parse_identifier] PASSED                                           [ 66%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \t suffix-"prefix \\t suffix"-parse_n3_identifier] PASSED                                        [ 66%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x08 suffix-"prefix \\b suffix"-parse_identifier] PASSED                                     [ 67%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x08 suffix-'prefix \\b suffix'-parse_identifier] PASSED                                     [ 67%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x08 suffix-'''prefix \\b suffix'''-parse_identifier] PASSED                                 [ 68%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x08 suffix-"""prefix \\b suffix"""-parse_identifier] PASSED                                 [ 68%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x08 suffix-"prefix \\b suffix"-parse_identifier] PASSED                                       [ 69%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x08 suffix-'prefix \\b suffix'-parse_identifier] PASSED                                       [ 69%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x08 suffix-'''prefix \\b suffix'''-parse_identifier] PASSED                                   [ 70%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x08 suffix-"""prefix \\b suffix"""-parse_identifier] PASSED                                   [ 70%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \x08 suffix-"prefix \\b suffix"-parse_identifier] PASSED                                         [ 71%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \x08 suffix-"prefix \\b suffix"-parse_n3_identifier] PASSED                                      [ 71%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \n suffix-"prefix \\n suffix"-parse_identifier] PASSED                                       [ 72%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \n suffix-'prefix \\n suffix'-parse_identifier] PASSED                                       [ 72%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \n suffix-'''prefix \\n suffix'''-parse_identifier] PASSED                                   [ 73%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \n suffix-"""prefix \\n suffix"""-parse_identifier] PASSED                                   [ 73%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \n suffix-"prefix \\n suffix"-parse_identifier] PASSED                                         [ 74%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \n suffix-'prefix \\n suffix'-parse_identifier] PASSED                                         [ 74%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \n suffix-'''prefix \\n suffix'''-parse_identifier] PASSED                                     [ 75%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \n suffix-"""prefix \\n suffix"""-parse_identifier] PASSED                                     [ 75%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \n suffix-"prefix \\n suffix"-parse_identifier] PASSED                                           [ 75%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \n suffix-"prefix \\n suffix"-parse_n3_identifier] PASSED                                        [ 76%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \r suffix-"prefix \\r suffix"-parse_identifier] PASSED                                       [ 76%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \r suffix-'prefix \\r suffix'-parse_identifier] PASSED                                       [ 77%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \r suffix-'''prefix \\r suffix'''-parse_identifier] PASSED                                   [ 77%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \r suffix-"""prefix \\r suffix"""-parse_identifier] PASSED                                   [ 78%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \r suffix-"prefix \\r suffix"-parse_identifier] PASSED                                         [ 78%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \r suffix-'prefix \\r suffix'-parse_identifier] PASSED                                         [ 79%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \r suffix-'''prefix \\r suffix'''-parse_identifier] PASSED                                     [ 79%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \r suffix-"""prefix \\r suffix"""-parse_identifier] PASSED                                     [ 80%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \r suffix-"prefix \\r suffix"-parse_identifier] PASSED                                           [ 80%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \r suffix-"prefix \\r suffix"-parse_n3_identifier] PASSED                                        [ 81%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x0c suffix-"prefix \\f suffix"-parse_identifier] PASSED                                     [ 81%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x0c suffix-'prefix \\f suffix'-parse_identifier] PASSED                                     [ 82%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x0c suffix-'''prefix \\f suffix'''-parse_identifier] PASSED                                 [ 82%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \x0c suffix-"""prefix \\f suffix"""-parse_identifier] PASSED                                 [ 83%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x0c suffix-"prefix \\f suffix"-parse_identifier] PASSED                                       [ 83%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x0c suffix-'prefix \\f suffix'-parse_identifier] PASSED                                       [ 83%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x0c suffix-'''prefix \\f suffix'''-parse_identifier] PASSED                                   [ 84%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \x0c suffix-"""prefix \\f suffix"""-parse_identifier] PASSED                                   [ 84%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \x0c suffix-"prefix \\f suffix"-parse_identifier] PASSED                                         [ 85%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \x0c suffix-"prefix \\f suffix"-parse_n3_identifier] PASSED                                      [ 85%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix " suffix-"prefix \\" suffix"-parse_identifier] PASSED                                        [ 86%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix " suffix-'prefix \\" suffix'-parse_identifier] PASSED                                        [ 86%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix " suffix-'''prefix \\" suffix'''-parse_identifier] PASSED                                    [ 87%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix " suffix-"""prefix \\" suffix"""-parse_identifier] PASSED                                    [ 87%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix " suffix-"prefix \\" suffix"-parse_identifier] PASSED                                          [ 88%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix " suffix-'prefix \\" suffix'-parse_identifier] PASSED                                          [ 88%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix " suffix-'''prefix \\" suffix'''-parse_identifier] PASSED                                      [ 89%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix " suffix-"""prefix \\" suffix"""-parse_identifier] PASSED                                      [ 89%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix " suffix-"prefix \\" suffix"-parse_identifier] PASSED                                            [ 90%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix " suffix-"prefix \\" suffix"-parse_n3_identifier] PASSED                                         [ 90%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix ' suffix-"prefix \\' suffix"-parse_identifier] PASSED                                        [ 91%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix ' suffix-'prefix \\' suffix'-parse_identifier] PASSED                                        [ 91%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix ' suffix-'''prefix \\' suffix'''-parse_identifier] PASSED                                    [ 91%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix ' suffix-"""prefix \\' suffix"""-parse_identifier] PASSED                                    [ 92%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix ' suffix-"prefix \\' suffix"-parse_identifier] PASSED                                          [ 92%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix ' suffix-'prefix \\' suffix'-parse_identifier] PASSED                                          [ 93%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix ' suffix-'''prefix \\' suffix'''-parse_identifier] PASSED                                      [ 93%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix ' suffix-"""prefix \\' suffix"""-parse_identifier] PASSED                                      [ 94%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix ' suffix-"prefix \\' suffix"-parse_identifier] PASSED                                            [ 94%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix ' suffix-"prefix \\' suffix"-parse_n3_identifier] PASSED                                         [ 95%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \\ suffix-"prefix \\\\ suffix"-parse_identifier] PASSED                                      [ 95%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \\ suffix-'prefix \\\\ suffix'-parse_identifier] PASSED                                      [ 96%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \\ suffix-'''prefix \\\\ suffix'''-parse_identifier] PASSED                                  [ 96%]
test/test_parsers/test_parser_turtlelike.py::test_literals[turtle-prefix \\ suffix-"""prefix \\\\ suffix"""-parse_identifier] PASSED                                  [ 97%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \\ suffix-"prefix \\\\ suffix"-parse_identifier] PASSED                                        [ 97%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \\ suffix-'prefix \\\\ suffix'-parse_identifier] PASSED                                        [ 98%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \\ suffix-'''prefix \\\\ suffix'''-parse_identifier] PASSED                                    [ 98%]
test/test_parsers/test_parser_turtlelike.py::test_literals[trig-prefix \\ suffix-"""prefix \\\\ suffix"""-parse_identifier] PASSED                                    [ 99%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \\ suffix-"prefix \\\\ suffix"-parse_identifier] PASSED                                          [ 99%]
test/test_parsers/test_parser_turtlelike.py::test_literals[n3-prefix \\ suffix-"prefix \\\\ suffix"-parse_n3_identifier] PASSED                                       [100%]

Copy link
Member

@aucampia aucampia left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @gjhiggins

There are still some corner cases that won't be handled so I'm still somewhat hesitant to invest much more into this function, I think the next step is to rewrite it to using the actual parser or deprecate it, but I think it is a marked improvement and I there are no regressions as far as I can tell.

@aucampia
Copy link
Member

aucampia commented Apr 2, 2022

Will merge later tonight if there is no more feedback.

@aucampia aucampia merged commit d55957f into RDFLib:master Apr 3, 2022
@aucampia aucampia linked an issue Apr 9, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

from_n3 fails on numeric shortcuts
2 participants