Fixed and refactored roundtrip, n3_suite and nt_suite tests by aucampia · Pull Request #1644 · RDFLib/rdflib (original) (raw)
Issues in previous roundtrip that are fixed:
Roundtrip tests were skipping tests that would fail instead of reporting them with xfail. While this is maybe a minor distinction it is more appropriate to report as xfail as that is a better semantic description of a known issue. Skipping should be reserved for tests that are expected to succeed when ran but can only run in a suitable environment (e.g. if berkleydb is installed). Furthermore, marking tests with xfail will still run the test, and will also report them as unexpected pass (xpass) if they do actually pass.
Removed ("json-ld", "example-misc.n3") from xfail/skip as it does pass.
Refactoring and improvements:
- Removed
test/test_n3_suite.py::test_n3_writing
. This test was doing something functionally equivalent to whattest/test_roundtrip.py::test_n3
would do, except it was doing it with different code (test/testutils.py::check_serialize_parse
). Specifically it would test, parse from n3, serialize to n3, parse from n3, and this is also something thattest/test_roundtrip.py::test_n3
does. One difference is thatcheck_serialize_parse
was usingcrapCompare
instead ofrdflib.compare.isomorphic
, andcrapCompare
does a significantly worse job but also hides an issue withrdflib.compare.isomorphic
and quoted graphs which is now correctly reported as xfail. - Removed
_get_test_files_formats
andall_{n3,nt}_files
fromtest/test_{nt,n3}_suite.py
(and removed the files since there is nothing else in them of value). These are now replaced with code insidetest/test_roundtrip.py
which has less duplication and usesguess_format
for determinering formats instead of a custom if/elif block. - Change skipping/xfail to work on file basename instead of path.
- Changed file collector from a generator to a function returning a list as the result of this function is iteratred over multiple times.
- Changed test id's to be more meningful, e.g.
roundtrip_n3-writer-test-28.n3_n3_trig
instead ofroundtrip-args303
.
Other changes:
- Renamed
test/nt/test.ntriples
->test/nt/test.nt
: .ntriples is not a recognized extension and the test this is being used in does not test anything pertaining to extention handling. - Add guess_format tests for
.{rdf,nt,n3}
and negative tests for.{docx,mkv}
and a file with no extension.