Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../lib2to3/fixes
File: fix_asserts.py
"""Fixer that replaces deprecated unittest method names."""
[0] Fix | Delete
[1] Fix | Delete
# Author: Ezio Melotti
[2] Fix | Delete
[3] Fix | Delete
from ..fixer_base import BaseFix
[4] Fix | Delete
from ..fixer_util import Name
[5] Fix | Delete
[6] Fix | Delete
NAMES = dict(
[7] Fix | Delete
assert_="assertTrue",
[8] Fix | Delete
assertEquals="assertEqual",
[9] Fix | Delete
assertNotEquals="assertNotEqual",
[10] Fix | Delete
assertAlmostEquals="assertAlmostEqual",
[11] Fix | Delete
assertNotAlmostEquals="assertNotAlmostEqual",
[12] Fix | Delete
assertRegexpMatches="assertRegex",
[13] Fix | Delete
assertRaisesRegexp="assertRaisesRegex",
[14] Fix | Delete
failUnlessEqual="assertEqual",
[15] Fix | Delete
failIfEqual="assertNotEqual",
[16] Fix | Delete
failUnlessAlmostEqual="assertAlmostEqual",
[17] Fix | Delete
failIfAlmostEqual="assertNotAlmostEqual",
[18] Fix | Delete
failUnless="assertTrue",
[19] Fix | Delete
failUnlessRaises="assertRaises",
[20] Fix | Delete
failIf="assertFalse",
[21] Fix | Delete
)
[22] Fix | Delete
[23] Fix | Delete
[24] Fix | Delete
class FixAsserts(BaseFix):
[25] Fix | Delete
[26] Fix | Delete
PATTERN = """
[27] Fix | Delete
power< any+ trailer< '.' meth=(%s)> any* >
[28] Fix | Delete
""" % '|'.join(map(repr, NAMES))
[29] Fix | Delete
[30] Fix | Delete
def transform(self, node, results):
[31] Fix | Delete
name = results["meth"][0]
[32] Fix | Delete
name.replace(Name(NAMES[str(name)], prefix=name.prefix))
[33] Fix | Delete
[34] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function