Debian Codegraph @

test/test_pickle.py

raw symbols SCIP
1 #! /usr/bin/env python3
2 # $Id: test_pickle.py 9277 2022-11-26 23:15:13Z milde $
3 # Author: David Goodger <[email protected]>
4 # Copyright: This module has been placed in the public domain.
5
6 """
7 Tests of document tree pickling.
8 """
9
10 from pathlib import Path
11 import pickle
12 import sys
13 import unittest
14
15 if __name__ == '__main__':
16 # prepend the "docutils root" to the Python library path
17 # so we import the local `docutils` package.
18 sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
19
20 from docutils import core
21
22
23 class PickleTests(unittest.TestCase):
24
25 def test_pickle(self):
26 doctree = core.publish_doctree(
27 source='Title\n=====\n\nparagraph\n',
28 settings_overrides={'_disable_config': True})
29 dill = pickle.dumps(doctree)
30 reconstituted = pickle.loads(dill)
31 self.assertEqual(doctree.pformat(), reconstituted.pformat())
32
33
34 if __name__ == '__main__':
35 unittest.main()