Jon Waltman  committed 4810618

Fix minor bugs in causing tests to fail under python 2.5

os.path.relpath not defined in Python 2.5, use equivalent from

Also avoid trying to create an existing directory when remnants exist
of an earlier failed build

  • Participants
  • Parent commits 46ee365

Comments (0)

Files changed (1)

File tests/

 import os
 from StringIO import StringIO
+from sphinx.util.pycompat import relpath
 from util import *
 from util import SkipTest
 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):
         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():
                 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
                 stdout, stderr = p.communicate()