From 31f5e876a56f3a1bad58d65b5313523741065335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Neuh=C3=A4user?= Date: Sun, 15 Aug 2010 18:08:00 +0200 Subject: [PATCH 1/3] Return doctree in get_old_doctree --- sphinx/builders/versioning.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sphinx/builders/versioning.py b/sphinx/builders/versioning.py index c47dcc98a..6c2bccca4 100644 --- a/sphinx/builders/versioning.py +++ b/sphinx/builders/versioning.py @@ -40,6 +40,7 @@ class VersioningBuilderMixin(object): doctree.settings.env = self.env doctree.reporter = Reporter(self.env.doc2path(docname), 2, 5, stream=WarningStream(self.env._warnfunc)) + return doctree def resave_doctree(self, docname, doctree): reporter = doctree.reporter From 37cc185fe789d91f6e40302ad100d05c882474b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Neuh=C3=A4user?= Date: Sun, 15 Aug 2010 18:41:14 +0200 Subject: [PATCH 2/3] Added a test for paragraphs inserted at the beginning of a document --- tests/root/versioning/index.txt | 1 + tests/root/versioning/insert_beginning.txt | 18 ++++++++++++++++++ tests/test_versioning.py | 7 +++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/root/versioning/insert_beginning.txt diff --git a/tests/root/versioning/index.txt b/tests/root/versioning/index.txt index 234e223f1..a6d12007c 100644 --- a/tests/root/versioning/index.txt +++ b/tests/root/versioning/index.txt @@ -9,3 +9,4 @@ Versioning Stuff deleted deleted_end modified + insert_beginning diff --git a/tests/root/versioning/insert_beginning.txt b/tests/root/versioning/insert_beginning.txt new file mode 100644 index 000000000..57102a76c --- /dev/null +++ b/tests/root/versioning/insert_beginning.txt @@ -0,0 +1,18 @@ +Versioning test text +==================== + +Apperantly inserting a paragraph at the beginning of a document caused +problems earlier so this document should be used to test that. + +So the thing is I need some kind of text - not the lorem ipsum stuff, that +doesn't work out that well - to test :mod:`sphinx.versioning`. I couldn't find +a good text for that under public domain so I thought the easiest solution is +to write one by myself. It's not really interesting, in fact it is *really* +boring. + +Anyway I need more than one paragraph, at least three for the original +document, I think, and another one for two different ones. + +So the previous paragraph was a bit short because I don't want to test this +only on long paragraphs, I hope it was short enough to cover most stuff. +Anyway I see this lacks ``some markup`` so I have to add a **little** bit. diff --git a/tests/test_versioning.py b/tests/test_versioning.py index 54a48f4ad..549d760f8 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -102,3 +102,10 @@ def test_insert(): assert len(new_nodes) == 1 assert original_uids[0] == uids[0] assert original_uids[1:] == uids[2:] + +def test_insert_beginning(): + insert_beginning = doctrees['versioning/insert_beginning'] + new_nodes = list(merge_doctrees(original, insert_beginning, is_paragraph)) + uids = [n.uid for n in insert_beginning.traverse(is_paragraph)] + assert len(new_nodes) == 1 + assert original_uids == uids[1:] From 6ac27b4da77119b11b9e5538483e0f6c9da4b5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Neuh=C3=A4user?= Date: Sun, 15 Aug 2010 18:44:09 +0200 Subject: [PATCH 3/3] Check also for the length and explicitly check that the first uids are different --- tests/test_versioning.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_versioning.py b/tests/test_versioning.py index 549d760f8..136faa1c4 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -108,4 +108,6 @@ def test_insert_beginning(): new_nodes = list(merge_doctrees(original, insert_beginning, is_paragraph)) uids = [n.uid for n in insert_beginning.traverse(is_paragraph)] assert len(new_nodes) == 1 + assert len(uids) == 4 assert original_uids == uids[1:] + assert original_uids[0] != uids[0]