r54014 - sandbox/trunk/2to3/tests/support.py sandbox/trunk/2to3/tests/test_fixers.py

Author: collin.winter Date: Wed Feb 28 02:33:51 2007 New Revision: 54014 Modified: sandbox/trunk/2to3/tests/support.py sandbox/trunk/2to3/tests/test_fixers.py Log: Move reformat() into tests.support Modified: sandbox/trunk/2to3/tests/support.py ============================================================================== --- sandbox/trunk/2to3/tests/support.py (original) +++ sandbox/trunk/2to3/tests/support.py Wed Feb 28 02:33:51 2007 @@ -4,14 +4,26 @@ import unittest import sys import os.path +import re + +TestCase = unittest.TestCase def run_all_tests(test_mod=None, tests=None): if tests is None: tests = unittest.TestLoader().loadTestsFromModule(test_mod) unittest.TextTestRunner(verbosity=2).run(tests) + def adjust_path(): parent_dir = os.path.split(sys.path[0])[0] sys.path = [parent_dir] + sys.path -TestCase = unittest.TestCase + +skip_whitespace = re.compile(r"""\S""") +def reformat(string): + indent = re.search(skip_whitespace, string).start() + if indent == 0: + code = string + else: + code = "\n".join(line[indent-1:] for line in string.split("\n")[1:]) + return code + "\n\n" Modified: sandbox/trunk/2to3/tests/test_fixers.py ============================================================================== --- sandbox/trunk/2to3/tests/test_fixers.py (original) +++ sandbox/trunk/2to3/tests/test_fixers.py Wed Feb 28 02:33:51 2007 @@ -9,7 +9,6 @@ # Python imports from StringIO import StringIO -import re import unittest import logging @@ -17,16 +16,6 @@ import pytree import refactor -skip_whitespace = re.compile(r"""\S""") - -def reformat(string): - indent = re.search(skip_whitespace, string).start() - if indent == 0: - code = string - else: - code = "\n".join(line[indent-1:] for line in string.split("\n")[1:]) - return code + "\n\n" - # We wrap the RefactoringTool's fixer objects so we can intercept # the call to set_filename() and so modify the fixers' logging objects. # This allows us to make sure that certain code chunks produce certain @@ -61,8 +50,8 @@ self.refactor.fixers = [Fixer(f, sh) for f in self.refactor.fixers] def check(self, before, after): - before = reformat(before) - after = reformat(after) + before = support.reformat(before) + after = support.reformat(after) refactored = self.refactor_stream("<string>", StringIO(before)) self.failUnlessEqual(after, refactored)
participants (1)
-
collin.winter