From f3d8aad161f3ba760b0626e2cf58b1094285f057 Mon Sep 17 00:00:00 2001 From: grubert Date: Sun, 30 Nov 2008 09:46:40 +0000 Subject: [PATCH] Prepare for python 3.0: use os.walk instead os.path.walk. git-svn-id: https://docutils.svn.sourceforge.net/svnroot/docutils/trunk/docutils@5739 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- HISTORY.txt | 1 + test/test_functional.py | 14 +++++++++++++- tools/buildhtml.py | 5 ++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index da509812e..44eb0b4aa 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -19,6 +19,7 @@ Changes Since 0.5 * General: + - Prepare for python 3.0: use os.walk instead os.path.walk. - Prepare for python 3.0: minimize "types" module where possible. - Apply [ 1878977 ] make_id(): deaccent characters. - Backwards-compatible changes to remove python2.6 -3 deprecation warnings diff --git a/test/test_functional.py b/test/test_functional.py index d2dff949d..91e1f5f40 100755 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -39,7 +39,19 @@ class FunctionalTestSuite(DocutilsTestSupport.CustomTestSuite): os.chdir(DocutilsTestSupport.testroot) self.clear_output_directory() self.added = 0 - os.path.walk(join_path(datadir, 'tests'), self.walker, None) + try: + for root, dirs, files in os.walk(join_path(datadir, 'tests')): + # Process all config files among `names` in `dirname`. A config + # file is a Python file (*.py) which sets several variables. + for name in files: + if name.endswith('.py') and not name.startswith('_'): + config_file_full_path = join_path(root, name) + self.addTestCase(FunctionalTestCase, 'test', None, None, + id=config_file_full_path, + configfile=config_file_full_path) + self.added += 1 + except (AttributeError): # python2.2 does not have os.walk + os.path.walk(join_path(datadir, 'tests'), self.walker, None) assert self.added, 'No functional tests found.' def clear_output_directory(self): diff --git a/tools/buildhtml.py b/tools/buildhtml.py index e5fda8293..f85f25d34 100755 --- a/tools/buildhtml.py +++ b/tools/buildhtml.py @@ -181,7 +181,10 @@ class Builder: else: self.directories = [os.getcwd()] for directory in self.directories: - os.path.walk(directory, self.visit, recurse) + try: + os.path.walk(directory, self.visit, recurse) + except (AttributeError): # python2.2 does not have os.walk + os.path.walk(directory, self.visit, recurse) def visit(self, recurse, directory, names): settings = self.get_settings('', directory) -- 2.11.4.GIT