ยปCore Development>Code coverage>Lib/lib2to3/fixes/fix_asserts.py

Python code coverage for Lib/lib2to3/fixes/fix_asserts.py

#countcontent
1n/a"""Fixer that replaces deprecated unittest method names."""
2n/a
3n/a# Author: Ezio Melotti
4n/a
5n/afrom ..fixer_base import BaseFix
6n/afrom ..fixer_util import Name
7n/a
8n/aNAMES = dict(
9n/a assert_="assertTrue",
10n/a assertEquals="assertEqual",
11n/a assertNotEquals="assertNotEqual",
12n/a assertAlmostEquals="assertAlmostEqual",
13n/a assertNotAlmostEquals="assertNotAlmostEqual",
14n/a assertRegexpMatches="assertRegex",
15n/a assertRaisesRegexp="assertRaisesRegex",
16n/a failUnlessEqual="assertEqual",
17n/a failIfEqual="assertNotEqual",
18n/a failUnlessAlmostEqual="assertAlmostEqual",
19n/a failIfAlmostEqual="assertNotAlmostEqual",
20n/a failUnless="assertTrue",
21n/a failUnlessRaises="assertRaises",
22n/a failIf="assertFalse",
23n/a)
24n/a
25n/a
26n/aclass FixAsserts(BaseFix):
27n/a
28n/a PATTERN = """
29n/a power< any+ trailer< '.' meth=(%s)> any* >
30n/a """ % '|'.join(map(repr, NAMES))
31n/a
32n/a def transform(self, node, results):
33n/a name = results["meth"][0]
34n/a name.replace(Name(NAMES[str(name)], prefix=name.prefix))