Beispiel #1
0
    def check_refactor(refactorer, source, expected):
        """
        Raises an AssertionError if the given
        lib2to3.refactor.RefactoringTool does not refactor 'source' into
        'expected'.

        source, expected -- strings (typically with Python code).
        """

        new = unicode(refactorer.refactor_string(support.reformat(source), "<string>"))

        assert support.reformat(expected) == new, "Refactoring failed: '{}' => '{}' instead of '{}'".format(
            source, new.strip(), expected
        )
Beispiel #2
0
    def check_refactor(refactorer, source, expected):
        """
        Raises an AssertionError if the given
        lib2to3.refactor.RefactoringTool does not refactor 'source' into
        'expected'.

        source, expected -- strings (typically with Python code).
        """

        new = unicode(
            refactorer.refactor_string(support.reformat(source), '<string>'))

        assert support.reformat(expected) == new, (
            "Refactoring failed: '{}' => '{}' instead of '{}'".format(
                source, new.strip(), expected))
Beispiel #3
0
    def check_refactor(refactorer, source, expected):
        """
        Raises an AssertionError if the given
        lib2to3.refactor.RefactoringTool does not refactor 'source' into
        'expected'.

        source, expected -- strings (typically with Python code).
        """

        # !! str() is from future's builtins and is only needed for Python 2,
        # where it is mostly equivalent to unicode():
        new = str(
            refactorer.refactor_string(support.reformat(source), '<string>'))

        assert support.reformat(expected) == new, (
            "Refactoring failed: '{}' => '{}' instead of '{}'".format(
                source, new.strip(), expected))