From 682cc714853be29d142558b771d14c76c340918f Mon Sep 17 00:00:00 2001 From: strank Date: Fri, 25 Jul 2008 06:43:16 +0000 Subject: Special-case tests with IOError on older python versions. git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/abolish-userstring-haskey@5616 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_parsers/test_rst/test_directives/test_raw.py | 12 +++++++++++- test/test_parsers/test_rst/test_directives/test_tables.py | 14 +++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/test/test_parsers/test_rst/test_directives/test_raw.py b/test/test_parsers/test_rst/test_directives/test_raw.py index 06354acae..1e2d9c5ca 100755 --- a/test/test_parsers/test_rst/test_directives/test_raw.py +++ b/test/test_parsers/test_rst/test_directives/test_raw.py @@ -157,7 +157,7 @@ Raw input file is UTF-16-encoded, and is not valid ASCII. .. raw:: html :file: non-existent.file -"""], +"""], # note that this output is rewritten below for certain python versions ] # Skip tests whose output contains "UnicodeDecodeError" if we are not @@ -171,6 +171,16 @@ if sys.version_info < (2, 3): # Assume we have only one of these tests. break +# Rewrite tests that depend on the output of IOError as it is +# platform-dependent before python 2.4 for a unicode path. +if sys.version_info < (2, 4): + # remove the unicode repr u except for py2.3 on windows: + if not sys.platform.startswith('win') or sys.version_info < (2, 3): + for i in range(len(totest['raw'])): + if totest['raw'][i][1].find("u'non-existent.file'") != -1: + totest['raw'][i][1] = totest['raw'][i][1].replace( + "u'non-existent.file'", "'non-existent.file'") + if __name__ == '__main__': import unittest diff --git a/test/test_parsers/test_rst/test_directives/test_tables.py b/test/test_parsers/test_rst/test_directives/test_tables.py index d474419d5..d97516767 100755 --- a/test/test_parsers/test_rst/test_directives/test_tables.py +++ b/test/test_parsers/test_rst/test_directives/test_tables.py @@ -566,7 +566,7 @@ u"""\ .. csv-table:: no such file :file: bogus.csv -"""], +"""], # note that this output is rewritten below for certain python versions ["""\ .. csv-table:: bad URL :url: bogus.csv @@ -1074,6 +1074,18 @@ totest['list-table'] = [ ] +if csv: + # Rewrite csv tests that depend on the output of IOError as it is + # platform-dependent before python 2.4 for a unicode path. + # Here only needed for python 2.3 on non-windows + import sys + if sys.version_info < (2, 4) and not sys.platform.startswith('win'): + for i in range(len(totest['csv-table'])): + if totest['csv-table'][i][1].find("u'bogus.csv'") != -1: + totest['csv-table'][i][1] = totest['csv-table'][i][1].replace( + "u'bogus.csv'", "'bogus.csv'") + + if __name__ == '__main__': import unittest unittest.main(defaultTest='suite') -- cgit v1.2.1