| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 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 |
|
| 17 |
|
| 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() |