Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
lib2to3.tests.test_fixers.Test_dict Class Reference
Inheritance diagram for lib2to3.tests.test_fixers.Test_dict:
Inheritance graph
[legend]
Collaboration diagram for lib2to3.tests.test_fixers.Test_dict:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_prefix_preservation
def test_trailing_comment
def test_unchanged
def test_01
def test_02
def test_03
def test_04
def test_05
def test_06
def test_07
def test_08
def test_09
def test_10
def test_11
def test_12
def test_13
def test_14
def test_15
def test_16
def test_17
def test_18
def test_19
def test_20
def test_21
def test_22
def test_23
def test_24
def test_25
def test_26
def test_27
def test_14
def test_15
def test_17
def test_18
def test_19
def setUp
def check
def warns
def warns_unchanged
def unchanged
def assert_runs_after

Public Attributes

 refactor
 fixer_log
 filename

Static Public Attributes

string fixer = "dict"

Detailed Description

Definition at line 1203 of file test_fixers.py.


Member Function Documentation

def lib2to3.tests.test_fixers.FixerTestCase.assert_runs_after (   self,
  names 
) [inherited]

Definition at line 56 of file test_fixers.py.

00056 
00057     def assert_runs_after(self, *names):
00058         fixes = [self.fixer]
00059         fixes.extend(names)
00060         r = support.get_refactorer("lib2to3", fixes)
00061         (pre, post) = r.get_fixers()
00062         n = "fix_" + self.fixer
00063         if post and post[-1].__class__.__module__.endswith(n):
00064             # We're the last fixer to run
00065             return
00066         if pre and pre[-1].__class__.__module__.endswith(n) and not post:
00067             # We're the last in pre and post is empty
00068             return
00069         self.fail("Fixer run order (%s) is incorrect; %s should be last."\
00070                %(", ".join([x.__class__.__module__ for x in (pre+post)]), n))

Here is the call graph for this function:

def lib2to3.tests.test_fixers.FixerTestCase.check (   self,
  before,
  after,
  ignore_warnings = False 
) [inherited]

Definition at line 36 of file test_fixers.py.

00036 
00037     def check(self, before, after, ignore_warnings=False):
00038         tree = self._check(before, after)
00039         self.assertTrue(tree.was_changed)
00040         if not ignore_warnings:
00041             self.assertEqual(self.fixer_log, [])

Here is the call graph for this function:

def lib2to3.tests.test_fixers.FixerTestCase.setUp (   self,
  fix_list = None,
  fixer_pkg = "lib2to3",
  options = None 
) [inherited]

Definition at line 18 of file test_fixers.py.

00018 
00019     def setUp(self, fix_list=None, fixer_pkg="lib2to3", options=None):
00020         if fix_list is None:
00021             fix_list = [self.fixer]
00022         self.refactor = support.get_refactorer(fixer_pkg, fix_list, options)
00023         self.fixer_log = []
00024         self.filename = "<string>"
00025 
00026         for fixer in chain(self.refactor.pre_order,
00027                            self.refactor.post_order):
00028             fixer.log = self.fixer_log

Here is the caller graph for this function:

Definition at line 1271 of file test_fixers.py.

01271 
01272     def test_01(self):
01273         b = "d.keys()"
01274         a = "list(d.keys())"
01275         self.check(b, a)
01276 
01277         b = "a[0].foo().keys()"
01278         a = "list(a[0].foo().keys())"
01279         self.check(b, a)

Here is the call graph for this function:

Definition at line 1280 of file test_fixers.py.

01280 
01281     def test_02(self):
01282         b = "d.items()"
01283         a = "list(d.items())"
01284         self.check(b, a)

Here is the call graph for this function:

Definition at line 1285 of file test_fixers.py.

01285 
01286     def test_03(self):
01287         b = "d.values()"
01288         a = "list(d.values())"
01289         self.check(b, a)

Here is the call graph for this function:

Definition at line 1290 of file test_fixers.py.

01290 
01291     def test_04(self):
01292         b = "d.iterkeys()"
01293         a = "iter(d.keys())"
01294         self.check(b, a)

Here is the call graph for this function:

Definition at line 1295 of file test_fixers.py.

01295 
01296     def test_05(self):
01297         b = "d.iteritems()"
01298         a = "iter(d.items())"
01299         self.check(b, a)

Here is the call graph for this function:

Definition at line 1300 of file test_fixers.py.

01300 
01301     def test_06(self):
01302         b = "d.itervalues()"
01303         a = "iter(d.values())"
01304         self.check(b, a)

Here is the call graph for this function:

Definition at line 1305 of file test_fixers.py.

01305 
01306     def test_07(self):
01307         s = "list(d.keys())"
01308         self.unchanged(s)

Here is the call graph for this function:

Definition at line 1309 of file test_fixers.py.

01309 
01310     def test_08(self):
01311         s = "sorted(d.keys())"
01312         self.unchanged(s)

Here is the call graph for this function:

Definition at line 1313 of file test_fixers.py.

01313 
01314     def test_09(self):
01315         b = "iter(d.keys())"
01316         a = "iter(list(d.keys()))"
01317         self.check(b, a)

Here is the call graph for this function:

Definition at line 1318 of file test_fixers.py.

01318 
01319     def test_10(self):
01320         b = "foo(d.keys())"
01321         a = "foo(list(d.keys()))"
01322         self.check(b, a)

Here is the call graph for this function:

Definition at line 1323 of file test_fixers.py.

01323 
01324     def test_11(self):
01325         b = "for i in d.keys(): print i"
01326         a = "for i in list(d.keys()): print i"
01327         self.check(b, a)

Here is the call graph for this function:

Definition at line 1328 of file test_fixers.py.

01328 
01329     def test_12(self):
01330         b = "for i in d.iterkeys(): print i"
01331         a = "for i in d.keys(): print i"
01332         self.check(b, a)

Here is the call graph for this function:

Definition at line 1333 of file test_fixers.py.

01333 
01334     def test_13(self):
01335         b = "[i for i in d.keys()]"
01336         a = "[i for i in list(d.keys())]"
01337         self.check(b, a)

Here is the call graph for this function:

Definition at line 1338 of file test_fixers.py.

01338 
01339     def test_14(self):
01340         b = "[i for i in d.iterkeys()]"
01341         a = "[i for i in d.keys()]"
01342         self.check(b, a)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1408 of file test_fixers.py.

01408 
01409     def test_14(self):
01410         b = "[i for i in d.viewkeys()]"
01411         a = "[i for i in d.keys()]"
01412         self.check(b, a)

Here is the call graph for this function:

Definition at line 1343 of file test_fixers.py.

01343 
01344     def test_15(self):
01345         b = "(i for i in d.keys())"
01346         a = "(i for i in list(d.keys()))"
01347         self.check(b, a)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1413 of file test_fixers.py.

01413 
01414     def test_15(self):
01415         b = "(i for i in d.viewkeys())"
01416         a = "(i for i in d.keys())"
01417         self.check(b, a)

Here is the call graph for this function:

Definition at line 1348 of file test_fixers.py.

01348 
01349     def test_16(self):
01350         b = "(i for i in d.iterkeys())"
01351         a = "(i for i in d.keys())"
01352         self.check(b, a)

Here is the call graph for this function:

Definition at line 1353 of file test_fixers.py.

01353 
01354     def test_17(self):
01355         b = "iter(d.iterkeys())"
01356         a = "iter(d.keys())"
01357         self.check(b, a)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1418 of file test_fixers.py.

01418 
01419     def test_17(self):
01420         b = "iter(d.viewkeys())"
01421         a = "iter(d.keys())"
01422         self.check(b, a)

Here is the call graph for this function:

Definition at line 1358 of file test_fixers.py.

01358 
01359     def test_18(self):
01360         b = "list(d.iterkeys())"
01361         a = "list(d.keys())"
01362         self.check(b, a)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1423 of file test_fixers.py.

01423 
01424     def test_18(self):
01425         b = "list(d.viewkeys())"
01426         a = "list(d.keys())"
01427         self.check(b, a)

Here is the call graph for this function:

Definition at line 1363 of file test_fixers.py.

01363 
01364     def test_19(self):
01365         b = "sorted(d.iterkeys())"
01366         a = "sorted(d.keys())"
01367         self.check(b, a)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1428 of file test_fixers.py.

01428 
01429     def test_19(self):
01430         b = "sorted(d.viewkeys())"
01431         a = "sorted(d.keys())"
01432         self.check(b, a)

Here is the call graph for this function:

Definition at line 1368 of file test_fixers.py.

01368 
01369     def test_20(self):
01370         b = "foo(d.iterkeys())"
01371         a = "foo(iter(d.keys()))"
01372         self.check(b, a)

Here is the call graph for this function:

Definition at line 1373 of file test_fixers.py.

01373 
01374     def test_21(self):
01375         b = "print h.iterkeys().next()"
01376         a = "print iter(h.keys()).next()"
01377         self.check(b, a)

Here is the call graph for this function:

Definition at line 1378 of file test_fixers.py.

01378 
01379     def test_22(self):
01380         b = "print h.keys()[0]"
01381         a = "print list(h.keys())[0]"
01382         self.check(b, a)

Here is the call graph for this function:

Definition at line 1383 of file test_fixers.py.

01383 
01384     def test_23(self):
01385         b = "print list(h.iterkeys().next())"
01386         a = "print list(iter(h.keys()).next())"
01387         self.check(b, a)

Here is the call graph for this function:

Definition at line 1388 of file test_fixers.py.

01388 
01389     def test_24(self):
01390         b = "for x in h.keys()[0]: print x"
01391         a = "for x in list(h.keys())[0]: print x"
01392         self.check(b, a)

Here is the call graph for this function:

Definition at line 1393 of file test_fixers.py.

01393 
01394     def test_25(self):
01395         b = "d.viewkeys()"
01396         a = "d.keys()"
01397         self.check(b, a)

Here is the call graph for this function:

Definition at line 1398 of file test_fixers.py.

01398 
01399     def test_26(self):
01400         b = "d.viewitems()"
01401         a = "d.items()"
01402         self.check(b, a)

Here is the call graph for this function:

Definition at line 1403 of file test_fixers.py.

01403 
01404     def test_27(self):
01405         b = "d.viewvalues()"
01406         a = "d.values()"
01407         self.check(b, a)

Here is the call graph for this function:

Definition at line 1206 of file test_fixers.py.

01206 
01207     def test_prefix_preservation(self):
01208         b = "if   d. keys  (  )  : pass"
01209         a = "if   list(d. keys  (  ))  : pass"
01210         self.check(b, a)
01211 
01212         b = "if   d. items  (  )  : pass"
01213         a = "if   list(d. items  (  ))  : pass"
01214         self.check(b, a)
01215 
01216         b = "if   d. iterkeys  ( )  : pass"
01217         a = "if   iter(d. keys  ( ))  : pass"
01218         self.check(b, a)
01219 
01220         b = "[i for i in    d.  iterkeys(  )  ]"
01221         a = "[i for i in    d.  keys(  )  ]"
01222         self.check(b, a)
01223 
01224         b = "if   d. viewkeys  ( )  : pass"
01225         a = "if   d. keys  ( )  : pass"
01226         self.check(b, a)
01227 
01228         b = "[i for i in    d.  viewkeys(  )  ]"
01229         a = "[i for i in    d.  keys(  )  ]"
01230         self.check(b, a)

Here is the call graph for this function:

Definition at line 1231 of file test_fixers.py.

01231 
01232     def test_trailing_comment(self):
01233         b = "d.keys() # foo"
01234         a = "list(d.keys()) # foo"
01235         self.check(b, a)
01236 
01237         b = "d.items()  # foo"
01238         a = "list(d.items())  # foo"
01239         self.check(b, a)
01240 
01241         b = "d.iterkeys()  # foo"
01242         a = "iter(d.keys())  # foo"
01243         self.check(b, a)
01244 
01245         b = """[i for i in d.iterkeys() # foo
01246                ]"""
01247         a = """[i for i in d.keys() # foo
01248                ]"""
01249         self.check(b, a)
01250 
01251         b = """[i for i in d.iterkeys() # foo
01252                ]"""
01253         a = """[i for i in d.keys() # foo
01254                ]"""
01255         self.check(b, a)
01256 
01257         b = "d.viewitems()  # foo"
01258         a = "d.items()  # foo"
01259         self.check(b, a)

Here is the call graph for this function:

Definition at line 1260 of file test_fixers.py.

01260 
01261     def test_unchanged(self):
01262         for wrapper in fixer_util.consuming_calls:
01263             s = "s = %s(d.keys())" % wrapper
01264             self.unchanged(s)
01265 
01266             s = "s = %s(d.values())" % wrapper
01267             self.unchanged(s)
01268 
01269             s = "s = %s(d.items())" % wrapper
01270             self.unchanged(s)

Here is the call graph for this function:

def lib2to3.tests.test_fixers.FixerTestCase.unchanged (   self,
  before,
  ignore_warnings = False 
) [inherited]

Definition at line 51 of file test_fixers.py.

00051 
00052     def unchanged(self, before, ignore_warnings=False):
00053         self._check(before, before)
00054         if not ignore_warnings:
00055             self.assertEqual(self.fixer_log, [])

Here is the call graph for this function:

def lib2to3.tests.test_fixers.FixerTestCase.warns (   self,
  before,
  after,
  message,
  unchanged = False 
) [inherited]

Definition at line 42 of file test_fixers.py.

00042 
00043     def warns(self, before, after, message, unchanged=False):
00044         tree = self._check(before, after)
00045         self.assertTrue(message in "".join(self.fixer_log))
00046         if not unchanged:
00047             self.assertTrue(tree.was_changed)

Here is the call graph for this function:

Here is the caller graph for this function:

def lib2to3.tests.test_fixers.FixerTestCase.warns_unchanged (   self,
  before,
  message 
) [inherited]

Definition at line 48 of file test_fixers.py.

00048 
00049     def warns_unchanged(self, before, message):
00050         self.warns(before, before, message, unchanged=True)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented in lib2to3.tests.test_fixers.Test_import.

Definition at line 23 of file test_fixers.py.

Definition at line 1204 of file test_fixers.py.

Definition at line 22 of file test_fixers.py.

Definition at line 21 of file test_fixers.py.


The documentation for this class was generated from the following file: