From bd5eb9f417748c448020c0a829158664fa9bdc93 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 19 Feb 2009 22:36:00 +0100 Subject: [PATCH] Fix a bug in FilenameUniqDict that led to test failures. --- sphinx/util/__init__.py | 7 ++++--- tests/test_build.py | 4 ++++ tests/util.py | 16 +++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 8449aff20..5f9462bed 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -307,7 +307,7 @@ class FilenameUniqDict(dict): def add_file(self, docname, newfile): if newfile in self: self[newfile][0].add(docname) - return + return self[newfile][1] uniquename = path.basename(newfile) base, ext = path.splitext(uniquename) i = 0 @@ -321,8 +321,9 @@ class FilenameUniqDict(dict): def purge_doc(self, docname): for filename, (docs, _) in self.items(): docs.discard(docname) - if not docs: - del self[filename] + #if not docs: + # del self[filename] + # self._existing.discard(filename) def __getstate__(self): return self._existing diff --git a/tests/test_build.py b/tests/test_build.py index 25d9a5cc6..c3286bfa3 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -30,6 +30,10 @@ from sphinx.builders.latex import LaTeXBuilder from sphinx.writers.latex import LaTeXTranslator +def teardown_module(): + (test_root / '_build').rmtree() + + html_warnfile = StringIO() latex_warnfile = StringIO() diff --git a/tests/util.py b/tests/util.py index 2130e20a0..2c9d3176e 100644 --- a/tests/util.py +++ b/tests/util.py @@ -159,10 +159,9 @@ def with_app(*args, **kwargs): @wraps(func) def deco(*args2, **kwargs2): app = TestApp(*args, **kwargs) - try: - return func(app, *args2, **kwargs2) - finally: - app.cleanup() + func(app, *args2, **kwargs2) + # don't execute cleanup if test failed + app.cleanup() return deco return generator @@ -176,11 +175,10 @@ def gen_with_app(*args, **kwargs): @wraps(func) def deco(*args2, **kwargs2): app = TestApp(*args, **kwargs) - try: - for item in func(app, *args2, **kwargs2): - yield item - finally: - app.cleanup() + for item in func(app, *args2, **kwargs2): + yield item + # don't execute cleanup if test failed + app.cleanup() return deco return generator