distutils2: b024621a1be6 (original) (raw)

Mercurial > distutils2

changeset 1277:b024621a1be6

Start improving 2to3 code (#13462). - Change the fixers used in tests to something not provided by lib2to3 - Test conversion of doctests in text files - Factor out test boilerplate into a common method

Éric Araujo merwok@netwok.org
date Thu, 09 Feb 2012 17:29:38 +0100
parents cfdf8964c3dc
children 8aca92f2fc25
files distutils2/compat.py distutils2/tests/fixer/fix_echo.py distutils2/tests/fixer/fix_echo2.py distutils2/tests/fixer/fix_idioms.py distutils2/tests/test_mixin2to3.py distutils2/util.py
diffstat 6 files changed, 99 insertions(+), 208 deletions(-)[+] [-] distutils2/compat.py 17 distutils2/tests/fixer/fix_echo.py 16 distutils2/tests/fixer/fix_echo2.py 16 distutils2/tests/fixer/fix_idioms.py 134 distutils2/tests/test_mixin2to3.py 106 distutils2/util.py 18

line wrap: on

line diff

--- a/distutils2/compat.py +++ b/distutils2/compat.py @@ -25,7 +25,7 @@ class Mixin2to3(_KLASS): """ if _CONVERT:

@@ -35,17 +35,16 @@ class Mixin2to3(_KLASS): if fixers: self.fixer_names = fixers

-

new file mode 100644 --- /dev/null +++ b/distutils2/tests/fixer/fix_echo.py @@ -0,0 +1,16 @@ +# Example custom fixer, derived from fix_raw_input by Andre Roberge + +from lib2to3 import fixer_base +from lib2to3.fixer_util import Name + + +class FixEcho(fixer_base.BaseFix): +

+

new file mode 100644 --- /dev/null +++ b/distutils2/tests/fixer/fix_echo2.py @@ -0,0 +1,16 @@ +# Example custom fixer, derived from fix_raw_input by Andre Roberge + +from lib2to3 import fixer_base +from lib2to3.fixer_util import Name + + +class FixEcho2(fixer_base.BaseFix): +

+

deleted file mode 100644 --- a/distutils2/tests/fixer/fix_idioms.py +++ /dev/null @@ -1,134 +0,0 @@ -"""Adjust some old Python 2 idioms to their modern counterparts. - -* Change some type comparisons to isinstance() calls:

- -* Change "while 1:" into "while True:". - -* Change both -

- -and the more general -

- -into -

-""" -# Author: Jacques Frechet, Collin Winter - -# Local imports -from lib2to3 import fixer_base -from lib2to3.fixer_util import Call, Comma, Name, Node, syms - -CMP = "(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)" -TYPE = "power< 'type' trailer< '(' x=any ')' > >" - -class FixIdioms(fixer_base.BaseFix): -

-

-

-

-

-

-

-

--- a/distutils2/tests/test_mixin2to3.py +++ b/distutils2/tests/test_mixin2to3.py @@ -9,91 +9,85 @@ class Mixin2to3TestCase(support.TempdirM support.LoggingCatcher, unittest.TestCase):

-

@unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher')

>>> print test test It works.

-

-

>>> print(test) test It works.

+

+

+

@unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') def test_additional_fixers(self):

-

-

-

-

-

def test_suite():

--- a/distutils2/util.py +++ b/distutils2/util.py @@ -862,13 +862,11 @@ def run_2to3(files, doctests_only=False, # Make this class local, to delay import of 2to3 from lib2to3.refactor import get_fixers_from_package, RefactoringTool

def run_2to3(self, files, doctests_only=False): """ Issues a call to util.run_2to3. """ return run_2to3(files, doctests_only, self.fixer_names, self.options, self.explicit)

+ + RICH_GLOB = re.compile(r'{([^}]*)}') _CHECK_RECURSIVE_GLOB = re.compile(r'[^/\,{]**|**[^/\,}]') _CHECK_MISMATCH_SET = re.compile(r'^[^{]}|{[^}]$')