From 29f768e48ff9922c6feaf08b4410ddfacb4cf440 Mon Sep 17 00:00:00 2001 From: Jonathan Waltman Date: Tue, 11 Dec 2012 01:36:50 -0600 Subject: [PATCH] Fix minor bugs in test_intl.py causing tests to fail under python 2.5 os.path.relpath not defined in Python 2.5, use equivalent from sphinx.util.pycompat Also avoid trying to create an existing directory when remnants exist of an earlier failed build --- tests/test_intl.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_intl.py b/tests/test_intl.py index 94b21e8d2..30854478d 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -15,6 +15,8 @@ import re import os from StringIO import StringIO +from sphinx.util.pycompat import relpath + from util import * from util import SkipTest @@ -23,6 +25,8 @@ warnfile = StringIO() def setup_module(): + # Delete remnants left over after failed build + (test_root / 'xx').rmtree(True) (test_root / 'xx' / 'LC_MESSAGES').makedirs() # Compile all required catalogs into binary format (*.mo). for dirpath, dirs, files in os.walk(test_root): @@ -30,18 +34,13 @@ def setup_module(): for f in [f for f in files if f.endswith('.po')]: po = dirpath / f mo = test_root / 'xx' / 'LC_MESSAGES' / ( - os.path.relpath(po[:-3], test_root) + '.mo') + relpath(po[:-3], test_root) + '.mo') if not mo.parent.exists(): mo.parent.makedirs() try: p = Popen(['msgfmt', po, '-o', mo], stdout=PIPE, stderr=PIPE) except OSError: - # The test will fail the second time it's run if we don't - # tear down here. Not sure if there's a more idiomatic way - # of ensuring that teardown gets run in the event of an - # exception from the setup function. - teardown_module() raise SkipTest # most likely msgfmt was not found else: stdout, stderr = p.communicate()