Exemplo n.º 1
0
    def e_test_pickling(self, tester=None, **options):
        if not hasattr(self,
                       "_can_test_pickling") or self._can_test_pickling():
            tester = self._tester(**options)
            from sage.misc.all import loads, dumps

            tester.assertEqual(loads(dumps(self)), self)
        else:
            tester.info(" (skipped, not picklable) ", newline=False)
Exemplo n.º 2
0
    def _test_pickling(self, **options):
        """
        Checks that the instance in self can be pickled and unpickled properly.

        EXAMPLES::

            sage: from sage.misc.sage_unittest import PythonObjectWithTests
            sage: PythonObjectWithTests(int(1))._test_pickling()

        SEE ALSO: :func:`dumps` :func:`loads`
        """
        tester = instance_tester(self, **options)
        from sage.misc.all import loads, dumps
        tester.assertEqual(loads(dumps(self._instance)), self._instance)