summaryrefslogtreecommitdiff
path: root/test/test_serializers
Commit message (Collapse)AuthorAgeFilesLines
* test: Eliminate flake8 errors in tests (#2353)Iwan Aucamp2023-04-141-4/+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)].
* refactor: eliminate inheritance from object (#2339)Iwan Aucamp2023-04-102-2/+2
| | | | | This change removes the redundant inheritance from `object` (i.e. `class Foo(object): pass`) that is no longer needed in Python 3 and is a relic from Python 2.
* fix: restore the 6.1.1 default bound namespaces (#2313)Iwan Aucamp2023-03-261-2/+2
| | | | | | | | | | | | The namespaces bound by default by `rdflib.graph.Graph` and `rdflib.namespace.NamespaceManager` was reduced in version 6.2.0 of RDFLib, however, this also would cause code that worked with 6.1.1 to break, so this constituted a breaking change. This change restores the previous behaviour, binding the same namespaces as was bound in 6.1.1. To bind a reduced set of namespaces, the `bind_namespaces` parameter of `rdflib.graph.Graph` or `rdflib.namespace.NamespaceManager` can be used. - Closes <https://github.com/RDFLib/rdflib/issues/2103>.
* fix: Add `to_dict` method to the JSON-LD `Context` class. (#2310)Iwan Aucamp2023-03-251-0/+44
| | | | | | | | | | `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>
* test: fix deprecation warnings (#2260)Iwan Aucamp2023-03-112-2/+2
| | | | This changes the test the code to avoid deprecation warnings that occur. Mostly related to changes in python threading and pytest.
* build(deps-dev): bump black from 22.12.0 to 23.1.0 (#2248)dependabot[bot]2023-03-114-10/+0
|
* build(deps-dev): bump mypy from 0.991 to 1.0.1 (#2247)dependabot[bot]2023-03-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | * build(deps-dev): bump mypy from 0.991 to 1.0.1 Bumps [mypy](https://github.com/python/mypy) from 0.991 to 1.0.1. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.991...v1.0.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix type errors --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
* Fix type errors resulting from new mypy (#2161)Iwan Aucamp2022-11-191-1/+2
| | | | | | New mypy version is reporting new errors. In the long run we need to switch to poetry so we can better control this.
* feat: Add type hints to rdflib.graph (#2080)Iwan Aucamp2022-08-231-1/+2
| | | | | | | | | | | | More or less complete type hints for the rdflib.graph module. Other changes: - Improved/simplified type hints in `rdflib.store` and store plugins. - Add type ignores for various type errors that occur with the type hints. This is split-off from <https://github.com/RDFLib/rdflib/pull/1850>. This PR does not change runtime behaviour.
* fix: issues with string destination handling in `{Graph,Result}.serialize` ↵Iwan Aucamp2022-08-021-52/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | (#2065) Change `{Graph,Result}.serialize` to only handle string destinations as URIs if the schema is `file` and to treat it as operating system paths in all other cases. This is for the following reasons: - `Result.serialize` was treating URI paths as OS paths which only works for some cases, for special charachters and percentage encoding it does not work. - Many valid Unix and Windows paths parse using `urlparse` and have no netloc, e.g. `C:\some\path` and `some:/path`, however they should be treated as paths and not as URIs. - `Graph` and `Result` should behave consistently. Some caveats in this change: - non-file URIs will now be treated as OS paths which may result in slightly confusing error messages, such as `FileNotFoundError: [Errno 2] No such file or directory: 'http://example.com/'` if http://example.com/ is passed. - some valid file URIs (e.g. `file:/path/to/file` from https://datatracker.ietf.org/doc/html/rfc8089) are also valid Posix paths but will be treated as file-URIs instead of Posix paths. For `Graph.serialize` this ambiguity can be avoided by using `pathlib.Path`, but for `Result.serialize` there is currently no way to avoid it, though I will work on https://github.com/RDFLib/rdflib/issues/1834 soon and in that provide a way to avoid the ambiguity there also.
* fix sonarcloud-reported bug in xmlwriter, add test (#1951)Graham Higgins2022-05-251-0/+79
| | | | | | | | | | | | | | | sonarcloud detected a bug: “Remove 1 unexpected arguments; 'join' expects 1 positional arguments.” in xmlwriter: ```py return ":".join(pre, uri[len(ns) :]) ``` Added containing brackets apparently omitted by original author. ```py return ":".join([pre, uri[len(ns) :]]) ``` Added test for surety, took the opportunity of adding two tests to take coverage of `xmlwriter` to 100%.
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-05-191-3/+3
| | | | for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-05-171-1/+0
| | | | for more information, see https://pre-commit.ci
* test: remove unused imports in test codeIwan Aucamp2022-05-172-3/+0
| | | | | | | | | | 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.
* fix: two issues with the N3 serializerIwan Aucamp2022-05-161-0/+150
| | | | | | | | | | | | | | | | | | | | | This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - https://github.com/RDFLib/rdflib/issues/1807 - https://github.com/RDFLib/rdflib/issues/1701
* test: Add more tests for Graph serializeIwan Aucamp2022-05-151-7/+520
| | | | This is to verify that all serialization options work for all graphs.
* test: move test utility modules into `test/utils/` (#1879)Iwan Aucamp2022-05-041-1/+1
| | | | | | | This patch moves all test utility modules into `test/utils/` and the tests for these modules into `test/utils/test/`. This is to make test utilities more organized and in preparation for adding more test utilities related to test suites.
* test: convert `test/test_serializers/test_serializer.py` to pytestIwan Aucamp2022-04-231-53/+46
| | | | | | This patch converts `test_serializer.py` to fairly idiomatic pytest in prepration for parameterized tests that I want to add to cover more cases.
* Merge remote-tracking branch 'upstream/master' into test-reorgIwan Aucamp2022-04-176-15/+14
|\
| * [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-156-15/+14
| | | | | | | | for more information, see https://pre-commit.ci
* | test re-orgGraham Higgins2022-04-161-8/+3
|/
* [pre-commit.ci] auto fixes from pre-commit.com hookspre-commit-ci[bot]2022-04-141-50/+193
| | | | for more information, see https://pre-commit.ci
* migrate yet more tests to pytestGraham Higgins2022-04-121-1/+1
|
* more test re-orgGraham Higgins2022-04-021-0/+27
|
* Migrate some tests to pytestGraham Higgins2022-03-241-67/+59
| | | | Preparatory work for dataset-rework, eases review
* extend test suite re-orgGraham Higgins2022-03-187-0/+1217