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:

  1. 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.

  2. Removed ("json-ld", "example-misc.n3") from xfail/skip as it does pass.

Refactoring and improvements:

  1. Removed test/test_n3_suite.py::test_n3_writing. This test was doing something functionally equivalent to what test/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 that test/test_roundtrip.py::test_n3 does. One difference is that check_serialize_parse was using crapCompare instead of rdflib.compare.isomorphic, and crapCompare does a significantly worse job but also hides an issue with rdflib.compare.isomorphic and quoted graphs which is now correctly reported as xfail.
  2. Removed _get_test_files_formats and all_{n3,nt}_files from test/test_{nt,n3}_suite.py (and removed the files since there is nothing else in them of value). These are now replaced with code inside test/test_roundtrip.py which has less duplication and uses guess_format for determinering formats instead of a custom if/elif block.
  3. Change skipping/xfail to work on file basename instead of path.
  4. Changed file collector from a generator to a function returning a list as the result of this function is iteratred over multiple times.
  5. Changed test id's to be more meningful, e.g. roundtrip_n3-writer-test-28.n3_n3_trig instead of roundtrip-args303.

Other changes:

  1. 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.
  2. Add guess_format tests for .{rdf,nt,n3} and negative tests for .{docx,mkv} and a file with no extension.