summaryrefslogtreecommitdiff
path: root/test/jsonld
Commit message (Collapse)AuthorAgeFilesLines
* test: Eliminate flake8 errors in tests (#2353)Iwan Aucamp2023-04-143-14/+1
| | | | | | | | | | | | | | | | | | | | | Eliminate some occurrences of the following flake8 errors in tests: * E265 block comment should start with '# ' * E266 too many leading '#' for block comment * E402 module level import not at top of file * E712 comparison to False should be 'if cond is False:' or 'if not cond:' * E712 comparison to True should be 'if cond is True:' or 'if cond:' * E722 do not use bare 'except' * F401 ... imported but unused * F403 ... used; unable to detect undefined names * F405 ... may be undefined, or defined from star imports: ... * F541 f-string is missing placeholders * F841 local variable 'result' is assigned to but never used * N806 variable 'TEST_DIR' in function should be lowercase This is pursuant to eliminating [flakeheaven](https://github.com/flakeheaven/flakeheaven), as it no longer supports the latest version of flake8 [[ref](https://github.com/flakeheaven/flakeheaven/issues/132)].
* fix: correct imports and `__all__` (#2340)Iwan Aucamp2023-04-125-7/+12
| | | | | | | | Disable [`implicit_reexport`](https://mypy.readthedocs.io/en/stable/config_file.html#confval-implicit_reexport) and eliminate all errors reported by mypy after this. This helps ensure that import statements import from the right module and that the `__all__` variable is correct.
* fix: Add `to_dict` method to the JSON-LD `Context` class. (#2310)Iwan Aucamp2023-03-251-0/+51
| | | | | | | | | | `Context.to_dict` is used in JSON-LD serialization, but it was not implemented. This change adds the method. - Closes <https://github.com/RDFLib/rdflib/issues/2138>. --------- Co-authored-by: Marc-Antoine Parent <maparent@acm.org>
* fix: JSON-LD context construction from a `dict` (#2306)Iwan Aucamp2023-03-241-0/+21
| | | | | | | | | | A variable was only being initialized for string-valued inputs, but if a `dict` input was passed the variable would still be accessed, resulting in a `UnboundLocalError`. This change initializes the variable always, instead of only when string-valued input is used to construct a JSON-LD context. - Closes <https://github.com/RDFLib/rdflib/issues/2303>.
* test: add `webtest` marker to tests that use the internet (#2295)Iwan Aucamp2023-03-211-0/+4
| | | | | | | | | | | This is being done so that it is easier for downstream packagers to run the test suite without requiring internet access. To run only tests that does not use the internet, run `pytest -m "not webtest"`. The validation workflow validates that test run without internet access by running the tests inside `firejail --net=none`. - Closes <https://github.com/RDFLib/rdflib/issues/2293>.
* fix: small InputSource related issues (#2255)Iwan Aucamp2023-03-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | I have added a bunch of tests for `InputSource` handling, checking most kinds of input source with most parsers. During this, I detected the following issues that I fixed: - `rdflib.util._iri2uri()` was URL quoting the `netloc` parameter, but this is wrong and the `idna` encoding already takes care of special characters. I removed the URL quoting of `netloc`. - HexTuple parsing was handling the input source in a way that would only work for some input sources, and not raising errors for other input sources. I changed the input source handling to be more generic. - `rdflib.parser.create_input_source()` incorrectly used `file.buffer` instead of `source.buffer` when dealing with IO stream sources. Other changes with no runtime impact include: - Changed the HTTP mocking stuff in test slightly to accommodate serving arbitrary files, as I used this in the `InputSource` tests. - Don't use Google in tests, as we keep getting `urllib.error.HTTPError: HTTP Error 429: Too Many Requests` from it.
* fix: don't modify base when processing context inputsHarold Solbrig2022-12-246-2/+25
| | | The the base URI passed to _prep_sources was being overwritten in anticipation of processing inner nestings, but this caused problems when processing multiple inputs. Changed the assignment to `base` to `new_base`.
* test: fix `None` comparisons (#1963)Iwan Aucamp2022-05-211-1/+1
| | | | `flake8` will eventually complain about this when the `flakeheaven` baseline is invalidated.
* Convert `test/jsonld/test_util.py` to pytest (#1961)Iwan Aucamp2022-05-211-83/+68
| | | | | | | | | Not the most straight forward conversion, but it simplifies it somewhat. Main reason for doing this is to remove the use of `unittest` `subTest` as we need `pytest-subtest` to process that with `pytest` and that dependency is causing some complications in dependency solving for pip sometimes. Merged with one review as this has no runtime impact.
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-05-191-2/+2
| | | | for more information, see https://pre-commit.ci
* Replace rdlib.net and rdflib.net with rdflib.github.io (#1901)Graham Higgins2022-05-191-1/+1
| | | | | | | | This is being done because `rdlib.net` is a typo and `rdflib.net` is not owned or associated with this project. Also: - Expand testing for some parts of the code impacted by this. Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
* test: remove unused imports in test codeIwan Aucamp2022-05-174-5/+2
| | | | | | | | | | This patch removes unused imports in test code. This is mainly to remove the potential snag for flake8/flakeheaven. The actual cleanup was done with `pycln --all test`. Also: - Remove superflous `pass` statements.
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-1510-23/+27
| | | | for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-144-26/+63
| | | | for more information, see https://pre-commit.ci
* Merge branch 'master' into jsonld_connegNicholas Car2021-12-293-6/+11
|\
| * Fix typing errors in testsIwan Aucamp2021-12-283-4/+7
| | | | | | | | | | | | | | | | Also removed mypy config to ignore errors in tests. This will make tests useful for determining if the typing of rdflib is correct and sane and should also help detect if a change in rdflib introduces typing errors in tests.
* | Merge branch 'master' into jsonld_connegNicholas Car2021-12-015-0/+127
|\ \ | |/
| * Merge pull request #1486 from RDFLib/new_json_ld_file_endingNicholas Car2021-12-013-0/+45
| |\ | | | | | | guess_format() cater for JSON-LD files ending .json-ld
| | * guess_format() cater for JSON-LD files ending .json-ldnicholascar2021-12-013-0/+45
| | |
| * | Merge pull request #1463 from joshmoore/python-graphNicholas Car2021-12-011-0/+76
| |\ \ | | | | | | | | RFC: Add PythonInputSource to create py-based graphs
| | * \ Merge remote-tracking branch 'origin/master' into python-graphjmoore2021-11-266-131/+209
| | |\ \ | | | |/
| | * | Run flake8jmoore2021-11-231-1/+1
| | | |
| | * | Run blackjmoore2021-11-231-4/+2
| | | |
| | * | Add equivalency test using isomorphicjmoore2021-11-231-6/+9
| | | |
| | * | Remove use of pytestjmoore2021-11-151-1/+0
| | | |
| | * | RFC: Add PythonInputSource to create py-based graphsjmoore2021-11-151-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to manipulate a JSON-LD structure before creating a graph (specifically to simplify rdf:Seq handling), it is currently necessary to use `json.loads` followed by `dumps` and then let `Graph().parse()` re-load. By detecting `dict` instances and creating a `PythonInputSource`, a single call to `loads` suffices.
| * | | Make the test pass on windowsIwan Aucamp2021-11-241-0/+6
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In rdflib: - Fix rdflib.plugins.shared.jsonld.util.norm_url on Windows On windows normpath and sep is not appropriate for URLs, use posixpath so that the behaviour is consistent. - Fix handling of file URIs in Graph.serialize on windows Should use url2pathname(path) to get a path from the path segment of URLs In tests: - Fix handling of file created by mkstemp Should first call os.close on the OS-level handle before removing the file. - Fix how file URIs are created so they work properly on windows. - Skip tests which are sensitive to unicode normalization and carriage return as these do not pass on windows (about 5 tests).
* | | Adapt for pytest and add back import of os in rdflib/parser.pyIwan Aucamp2021-11-281-23/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test/jsonld/test_onedotone.py got a bit messed up with a merge from master. Looking at the original changes from @ashleysommer, all he did was change a condition. This applies the same change but essentially rebased on master. For comparison see: https://github.com/RDFLib/rdflib/compare/ab31c5ed3772cb63806a4614ca4431e9bd7de8d3...c4b679ff6660f4287e7738c93c8c06072642ce1a Also add back import os in rdflib/parser.py This is now needed after https://github.com/RDFLib/rdflib/pull/1441 was merged.
* | | Update test/jsonld/test_onedotone.pyNicholas Car2021-11-211-1/+1
| | | | | | | | | Co-authored-by: Christian Clauss <cclauss@me.com>
* | | Update test/jsonld/test_onedotone.pyNicholas Car2021-11-211-1/+1
| | | | | | | | | Co-authored-by: Christian Clauss <cclauss@me.com>
* | | Update test/jsonld/runner.pyNicholas Car2021-11-211-1/+1
| | | | | | | | | Co-authored-by: Christian Clauss <cclauss@me.com>
* | | Merge branch 'master' into jsonld_connegNicholas Car2021-11-216-109/+207
|\ \ \ | |/ /
| * | Merge pull request #1456 from newinnovations/masterNicholas Car2021-11-211-0/+89
| |\ \ | | | | | | | | Fix JSON-LD data import adds trailing slashes to IRIs (#1443)
| | * | Add two additional tests for `norm_url`Iwan Aucamp2021-11-061-0/+10
| | | | | | | | | | | | | | | | Tests suggested by @newinnovations.
| | * | Add tests for norm_url.Iwan Aucamp2021-10-291-0/+79
| | |/
| * | Migrate from nosetest to pytestIwan Aucamp2021-10-245-131/+120
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replace all uses of nose with pytest. It also includes a pytest plugin for creating EARL reports for tests with a `rdf_test_uri` parameter. Some caveats: - HTML report directory is now htmlcov instead of coverage - There is some warning related to the EARL reporting plugin which I can't quite figure out: ``` .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) ``` This is not causing any problems as far as I can tell, but still annoying. - python setup.py test won't work anymore, I can make it work but this is not advised by pytest: https://github.com/pytest-dev/pytest-runner/#deprecation-notice - run_test.py is still there but it's not really referenced anymore from anywhere and the options it accepts are completely different as it's options were based on nose. I would say it should be removed entirely but for now it is basically just a wrapper around pytest that basically does nothing. - Removed references to test attributes as currently they are not being used anywhere anyway, I guess we can add them back if there is some use for them later. - A lot of tests are still marked to skip when really they should be marked with xfail. This is also affecting the RDFT test manifests and result in reports saying tests are skipped when really we know they will fail and they are only skipped for this reason. But there is no change here from before, and pytest makes it easier to dynamically do expected failures. Special thanks to Wes Turner for his advice and inputs on this process.
* | Allow URLInputSource to get content-negotiation links from the Link headers ↵Ashley Sommer2021-10-122-23/+77
|/ | | | | | of HTTP responses. Use Links to resolve schema.org-style json-ld conneg redirections. Fix the ability to run the `remote-url` arm of the JSON-LD test suite (got most of them working!)
* blacked everything6.0.0Nicholas Car2021-07-203-20/+61
|
* monkey-patch N3 parser in jsonld test-runner only when required, and unpatch ↵Ashley Sommer2021-07-091-4/+15
| | | | it when done
* some tests magically fixed themselves, remove them from known_bugsAshley Sommer2021-07-092-14/+6
|
* change directory back to cwd after running jsonld testsAshley Sommer2021-07-093-38/+49
|
* Investigated some more json-ld test failuresAshley Sommer2021-07-082-2/+7
|
* integrate jsonld code into rdflib coreAshley Sommer2021-07-072870-0/+44112