Back to index

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

List of all members.

Public Member Functions

def test_1
def test_2
def test_3
def test_4
def test_5
def test_6
def test_prefix_preservation_1
def test_prefix_preservation_2
def test_prefix_preservation_3
def test_prefix_preservation_4
def test_prefix_preservation_5
def test_prefix_preservation_6
def test_method_1
def test_method_2
def test_method_3
def test_method_4
def test_method_unchanged
def test_shadowing_assign_simple
def test_shadowing_assign_tuple_1
def test_shadowing_assign_tuple_2
def test_shadowing_assign_list_1
def test_shadowing_assign_list_2
def test_builtin_assign
def test_builtin_assign_in_tuple
def test_builtin_assign_in_list
def test_assign_to_next
def test_assign_to_next_in_tuple
def test_assign_to_next_in_list
def test_shadowing_import_1
def test_shadowing_import_2
def test_shadowing_import_3
def test_shadowing_import_from_1
def test_shadowing_import_from_2
def test_shadowing_import_from_3
def test_shadowing_import_from_4
def test_shadowing_funcdef_1
def test_shadowing_funcdef_2
def test_shadowing_global_1
def test_shadowing_global_2
def test_shadowing_for_simple
def test_shadowing_for_tuple_1
def test_shadowing_for_tuple_2
def test_noncall_access_1
def test_noncall_access_2
def test_noncall_access_3
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 = "next"

Detailed Description

Definition at line 2148 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 2151 of file test_fixers.py.

02151 
02152     def test_1(self):
02153         b = """it.next()"""
02154         a = """next(it)"""
02155         self.check(b, a)

Here is the call graph for this function:

Definition at line 2156 of file test_fixers.py.

02156 
02157     def test_2(self):
02158         b = """a.b.c.d.next()"""
02159         a = """next(a.b.c.d)"""
02160         self.check(b, a)

Here is the call graph for this function:

Definition at line 2161 of file test_fixers.py.

02161 
02162     def test_3(self):
02163         b = """(a + b).next()"""
02164         a = """next((a + b))"""
02165         self.check(b, a)

Here is the call graph for this function:

Definition at line 2166 of file test_fixers.py.

02166 
02167     def test_4(self):
02168         b = """a().next()"""
02169         a = """next(a())"""
02170         self.check(b, a)

Here is the call graph for this function:

Definition at line 2171 of file test_fixers.py.

02171 
02172     def test_5(self):
02173         b = """a().next() + b"""
02174         a = """next(a()) + b"""
02175         self.check(b, a)

Here is the call graph for this function:

Definition at line 2176 of file test_fixers.py.

02176 
02177     def test_6(self):
02178         b = """c(      a().next() + b)"""
02179         a = """c(      next(a()) + b)"""
02180         self.check(b, a)

Here is the call graph for this function:

Definition at line 2424 of file test_fixers.py.

02424 
02425     def test_assign_to_next(self):
02426         s = """
02427             def foo():
02428                 A.next = foo
02429 
02430             class A:
02431                 def next(self, a, b):
02432                     pass
02433             """
02434         self.unchanged(s)

Here is the call graph for this function:

Definition at line 2446 of file test_fixers.py.

02446 
02447     def test_assign_to_next_in_list(self):
02448         s = """
02449             def foo():
02450                 [a, A.next] = foo
02451 
02452             class A:
02453                 def next(self, a, b):
02454                     pass
02455             """
02456         self.unchanged(s)

Here is the call graph for this function:

Definition at line 2435 of file test_fixers.py.

02435 
02436     def test_assign_to_next_in_tuple(self):
02437         s = """
02438             def foo():
02439                 (a, A.next) = foo
02440 
02441             class A:
02442                 def next(self, a, b):
02443                     pass
02444             """
02445         self.unchanged(s)

Here is the call graph for this function:

Definition at line 2391 of file test_fixers.py.

02391 
02392     def test_builtin_assign(self):
02393         s = """
02394             def foo():
02395                 __builtin__.next = foo
02396 
02397             class A:
02398                 def next(self, a, b):
02399                     pass
02400             """
02401         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2413 of file test_fixers.py.

02413 
02414     def test_builtin_assign_in_list(self):
02415         s = """
02416             def foo():
02417                 [a, __builtin__.next] = foo
02418 
02419             class A:
02420                 def next(self, a, b):
02421                     pass
02422             """
02423         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2402 of file test_fixers.py.

02402 
02403     def test_builtin_assign_in_tuple(self):
02404         s = """
02405             def foo():
02406                 (a, __builtin__.next) = foo
02407 
02408             class A:
02409                 def next(self, a, b):
02410                     pass
02411             """
02412         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2269 of file test_fixers.py.

02269 
02270     def test_method_1(self):
02271         b = """
02272             class A:
02273                 def next(self):
02274                     pass
02275             """
02276         a = """
02277             class A:
02278                 def __next__(self):
02279                     pass
02280             """
02281         self.check(b, a)

Here is the call graph for this function:

Definition at line 2282 of file test_fixers.py.

02282 
02283     def test_method_2(self):
02284         b = """
02285             class A(object):
02286                 def next(self):
02287                     pass
02288             """
02289         a = """
02290             class A(object):
02291                 def __next__(self):
02292                     pass
02293             """
02294         self.check(b, a)

Here is the call graph for this function:

Definition at line 2295 of file test_fixers.py.

02295 
02296     def test_method_3(self):
02297         b = """
02298             class A:
02299                 def next(x):
02300                     pass
02301             """
02302         a = """
02303             class A:
02304                 def __next__(x):
02305                     pass
02306             """
02307         self.check(b, a)

Here is the call graph for this function:

Definition at line 2308 of file test_fixers.py.

02308 
02309     def test_method_4(self):
02310         b = """
02311             class A:
02312                 def __init__(self, foo):
02313                     self.foo = foo
02314 
02315                 def next(self):
02316                     pass
02317 
02318                 def __iter__(self):
02319                     return self
02320             """
02321         a = """
02322             class A:
02323                 def __init__(self, foo):
02324                     self.foo = foo
02325 
02326                 def __next__(self):
02327                     pass
02328 
02329                 def __iter__(self):
02330                     return self
02331             """
02332         self.check(b, a)

Here is the call graph for this function:

Definition at line 2333 of file test_fixers.py.

02333 
02334     def test_method_unchanged(self):
02335         s = """
02336             class A:
02337                 def next(self, a, b):
02338                     pass
02339             """
02340         self.unchanged(s)

Here is the call graph for this function:

Definition at line 2607 of file test_fixers.py.

02607 
02608     def test_noncall_access_1(self):
02609         b = """gnext = g.next"""
02610         a = """gnext = g.__next__"""
02611         self.check(b, a)

Here is the call graph for this function:

Definition at line 2612 of file test_fixers.py.

02612 
02613     def test_noncall_access_2(self):
02614         b = """f(g.next + 5)"""
02615         a = """f(g.__next__ + 5)"""
02616         self.check(b, a)

Here is the call graph for this function:

Definition at line 2617 of file test_fixers.py.

02617 
02618     def test_noncall_access_3(self):
02619         b = """f(g().next + 5)"""
02620         a = """f(g().__next__ + 5)"""
02621         self.check(b, a)

Here is the call graph for this function:

Definition at line 2181 of file test_fixers.py.

02181 
02182     def test_prefix_preservation_1(self):
02183         b = """
02184             for a in b:
02185                 foo(a)
02186                 a.next()
02187             """
02188         a = """
02189             for a in b:
02190                 foo(a)
02191                 next(a)
02192             """
02193         self.check(b, a)

Here is the call graph for this function:

Definition at line 2194 of file test_fixers.py.

02194 
02195     def test_prefix_preservation_2(self):
02196         b = """
02197             for a in b:
02198                 foo(a) # abc
02199                 # def
02200                 a.next()
02201             """
02202         a = """
02203             for a in b:
02204                 foo(a) # abc
02205                 # def
02206                 next(a)
02207             """
02208         self.check(b, a)

Here is the call graph for this function:

Definition at line 2209 of file test_fixers.py.

02209 
02210     def test_prefix_preservation_3(self):
02211         b = """
02212             next = 5
02213             for a in b:
02214                 foo(a)
02215                 a.next()
02216             """
02217         a = """
02218             next = 5
02219             for a in b:
02220                 foo(a)
02221                 a.__next__()
02222             """
02223         self.check(b, a, ignore_warnings=True)

Here is the call graph for this function:

Definition at line 2224 of file test_fixers.py.

02224 
02225     def test_prefix_preservation_4(self):
02226         b = """
02227             next = 5
02228             for a in b:
02229                 foo(a) # abc
02230                 # def
02231                 a.next()
02232             """
02233         a = """
02234             next = 5
02235             for a in b:
02236                 foo(a) # abc
02237                 # def
02238                 a.__next__()
02239             """
02240         self.check(b, a, ignore_warnings=True)

Here is the call graph for this function:

Definition at line 2241 of file test_fixers.py.

02241 
02242     def test_prefix_preservation_5(self):
02243         b = """
02244             next = 5
02245             for a in b:
02246                 foo(foo(a), # abc
02247                     a.next())
02248             """
02249         a = """
02250             next = 5
02251             for a in b:
02252                 foo(foo(a), # abc
02253                     a.__next__())
02254             """
02255         self.check(b, a, ignore_warnings=True)

Here is the call graph for this function:

Definition at line 2256 of file test_fixers.py.

02256 
02257     def test_prefix_preservation_6(self):
02258         b = """
02259             for a in b:
02260                 foo(foo(a), # abc
02261                     a.next())
02262             """
02263         a = """
02264             for a in b:
02265                 foo(foo(a), # abc
02266                     next(a))
02267             """
02268         self.check(b, a)

Here is the call graph for this function:

Definition at line 2371 of file test_fixers.py.

02371 
02372     def test_shadowing_assign_list_1(self):
02373         s = """
02374             [next, a] = foo
02375 
02376             class A:
02377                 def next(self, a, b):
02378                     pass
02379             """
02380         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2381 of file test_fixers.py.

02381 
02382     def test_shadowing_assign_list_2(self):
02383         s = """
02384             [a, [b, [next, c]], a] = foo
02385 
02386             class A:
02387                 def next(self, a, b):
02388                     pass
02389             """
02390         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2341 of file test_fixers.py.

02341 
02342     def test_shadowing_assign_simple(self):
02343         s = """
02344             next = foo
02345 
02346             class A:
02347                 def next(self, a, b):
02348                     pass
02349             """
02350         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2351 of file test_fixers.py.

02351 
02352     def test_shadowing_assign_tuple_1(self):
02353         s = """
02354             (next, a) = foo
02355 
02356             class A:
02357                 def next(self, a, b):
02358                     pass
02359             """
02360         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2361 of file test_fixers.py.

02361 
02362     def test_shadowing_assign_tuple_2(self):
02363         s = """
02364             (a, (b, (next, c)), a) = foo
02365 
02366             class A:
02367                 def next(self, a, b):
02368                     pass
02369             """
02370         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2577 of file test_fixers.py.

02577 
02578     def test_shadowing_for_simple(self):
02579         s = """
02580             for next in it():
02581                 pass
02582 
02583             b = 5
02584             c = 6
02585             """
02586         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2587 of file test_fixers.py.

02587 
02588     def test_shadowing_for_tuple_1(self):
02589         s = """
02590             for next, b in it():
02591                 pass
02592 
02593             b = 5
02594             c = 6
02595             """
02596         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2597 of file test_fixers.py.

02597 
02598     def test_shadowing_for_tuple_2(self):
02599         s = """
02600             for a, (next, c), b in it():
02601                 pass
02602 
02603             b = 5
02604             c = 6
02605             """
02606         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2527 of file test_fixers.py.

02527 
02528     def test_shadowing_funcdef_1(self):
02529         s = """
02530             def next(a):
02531                 pass
02532 
02533             class A:
02534                 def next(self, a, b):
02535                     pass
02536             """
02537         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2538 of file test_fixers.py.

02538 
02539     def test_shadowing_funcdef_2(self):
02540         b = """
02541             def next(a):
02542                 pass
02543 
02544             class A:
02545                 def next(self):
02546                     pass
02547 
02548             it.next()
02549             """
02550         a = """
02551             def next(a):
02552                 pass
02553 
02554             class A:
02555                 def __next__(self):
02556                     pass
02557 
02558             it.__next__()
02559             """
02560         self.warns(b, a, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2561 of file test_fixers.py.

02561 
02562     def test_shadowing_global_1(self):
02563         s = """
02564             def f():
02565                 global next
02566                 next = 5
02567             """
02568         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2569 of file test_fixers.py.

02569 
02570     def test_shadowing_global_2(self):
02571         s = """
02572             def f():
02573                 global a, next, b
02574                 next = 5
02575             """
02576         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2457 of file test_fixers.py.

02457 
02458     def test_shadowing_import_1(self):
02459         s = """
02460             import foo.bar as next
02461 
02462             class A:
02463                 def next(self, a, b):
02464                     pass
02465             """
02466         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2467 of file test_fixers.py.

02467 
02468     def test_shadowing_import_2(self):
02469         s = """
02470             import bar, bar.foo as next
02471 
02472             class A:
02473                 def next(self, a, b):
02474                     pass
02475             """
02476         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2477 of file test_fixers.py.

02477 
02478     def test_shadowing_import_3(self):
02479         s = """
02480             import bar, bar.foo as next, baz
02481 
02482             class A:
02483                 def next(self, a, b):
02484                     pass
02485             """
02486         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2487 of file test_fixers.py.

02487 
02488     def test_shadowing_import_from_1(self):
02489         s = """
02490             from x import next
02491 
02492             class A:
02493                 def next(self, a, b):
02494                     pass
02495             """
02496         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2497 of file test_fixers.py.

02497 
02498     def test_shadowing_import_from_2(self):
02499         s = """
02500             from x.a import next
02501 
02502             class A:
02503                 def next(self, a, b):
02504                     pass
02505             """
02506         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2507 of file test_fixers.py.

02507 
02508     def test_shadowing_import_from_3(self):
02509         s = """
02510             from x import a, next, b
02511 
02512             class A:
02513                 def next(self, a, b):
02514                     pass
02515             """
02516         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

Here is the call graph for this function:

Definition at line 2517 of file test_fixers.py.

02517 
02518     def test_shadowing_import_from_4(self):
02519         s = """
02520             from x.a import a, next, b
02521 
02522             class A:
02523                 def next(self, a, b):
02524                     pass
02525             """
02526         self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")

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 2149 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: