Mercurial > repos > shellac > guppy_basecaller
diff env/lib/python3.7/site-packages/prov/tests/utility.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
| author | shellac |
|---|---|
| date | Mon, 01 Jun 2020 08:59:25 -0400 |
| parents | 79f47841a781 |
| children |
line wrap: on
line diff
--- a/env/lib/python3.7/site-packages/prov/tests/utility.py Thu May 14 16:47:39 2020 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -from __future__ import (absolute_import, division, print_function, - unicode_literals) - -import io -import logging -import unittest - -from prov.model import ProvDocument - - -logger = logging.getLogger(__name__) - - -class DocumentBaseTestCase(unittest.TestCase): - def do_tests(self, prov_doc, msg=None): - pass - - -class RoundTripTestCase(DocumentBaseTestCase): - """A serializer test should subclass this class and set the class property - FORMAT to the correct value (e.g. 'json', 'xml', 'rdf'). - """ - FORMAT = None # a subclass should change this - - def do_tests(self, prov_doc, msg=None): - self.assertRoundTripEquivalence(prov_doc, msg) - - def assertRoundTripEquivalence(self, prov_doc, msg=None): - if self.FORMAT is None: - # This is a dummy test, just return - return - - with io.BytesIO() as stream: - prov_doc.serialize(destination=stream, format=self.FORMAT, indent=4) - stream.seek(0, 0) - - prov_doc_new = ProvDocument.deserialize(source=stream, - format=self.FORMAT) - stream.seek(0, 0) - # Assume UTF-8 encoding which is forced by the particular - # PROV XML implementation and should also work for the PROV - # JSON implementation. - msg_extra = u"'%s' serialization content:\n%s" % ( - self.FORMAT, stream.read().decode("utf-8")) - msg = u'\n'.join((msg, msg_extra)) if msg else msg_extra - self.assertEqual(prov_doc, prov_doc_new, msg)
