Back to index

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

List of all members.

Public Member Functions

def test_prefix_preservation
def test_single_arg
def test_two_args
def test_three_args
def test_wrap_in_list
def test_xrange_in_for
def test_range_in_for
def test_in_contains_test
def test_in_consuming_context
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 = "xrange"

Detailed Description

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

01501 
01502     def test_in_consuming_context(self):
01503         for call in fixer_util.consuming_calls:
01504             self.unchanged("a = %s(range(10))" % call)

Here is the call graph for this function:

Definition at line 1498 of file test_fixers.py.

01498 
01499     def test_in_contains_test(self):
01500         self.unchanged("x in range(10, 3, 9)")

Here is the call graph for this function:

Definition at line 1436 of file test_fixers.py.

01436 
01437     def test_prefix_preservation(self):
01438         b = """x =    xrange(  10  )"""
01439         a = """x =    range(  10  )"""
01440         self.check(b, a)
01441 
01442         b = """x = xrange(  1  ,  10   )"""
01443         a = """x = range(  1  ,  10   )"""
01444         self.check(b, a)
01445 
01446         b = """x = xrange(  0  ,  10 ,  2 )"""
01447         a = """x = range(  0  ,  10 ,  2 )"""
01448         self.check(b, a)

Here is the call graph for this function:

Definition at line 1494 of file test_fixers.py.

01494 
01495     def test_range_in_for(self):
01496         self.unchanged("for i in range(10): pass")
01497         self.unchanged("[i for i in range(10)]")

Here is the call graph for this function:

Definition at line 1449 of file test_fixers.py.

01449 
01450     def test_single_arg(self):
01451         b = """x = xrange(10)"""
01452         a = """x = range(10)"""
01453         self.check(b, a)

Here is the call graph for this function:

Definition at line 1459 of file test_fixers.py.

01459 
01460     def test_three_args(self):
01461         b = """x = xrange(0, 10, 2)"""
01462         a = """x = range(0, 10, 2)"""
01463         self.check(b, a)

Here is the call graph for this function:

Definition at line 1454 of file test_fixers.py.

01454 
01455     def test_two_args(self):
01456         b = """x = xrange(1, 10)"""
01457         a = """x = range(1, 10)"""
01458         self.check(b, a)

Here is the call graph for this function:

Definition at line 1464 of file test_fixers.py.

01464 
01465     def test_wrap_in_list(self):
01466         b = """x = range(10, 3, 9)"""
01467         a = """x = list(range(10, 3, 9))"""
01468         self.check(b, a)
01469 
01470         b = """x = foo(range(10, 3, 9))"""
01471         a = """x = foo(list(range(10, 3, 9)))"""
01472         self.check(b, a)
01473 
01474         b = """x = range(10, 3, 9) + [4]"""
01475         a = """x = list(range(10, 3, 9)) + [4]"""
01476         self.check(b, a)
01477 
01478         b = """x = range(10)[::-1]"""
01479         a = """x = list(range(10))[::-1]"""
01480         self.check(b, a)
01481 
01482         b = """x = range(10)  [3]"""
01483         a = """x = list(range(10))  [3]"""
01484         self.check(b, a)

Here is the call graph for this function:

Definition at line 1485 of file test_fixers.py.

01485 
01486     def test_xrange_in_for(self):
01487         b = """for i in xrange(10):\n    j=i"""
01488         a = """for i in range(10):\n    j=i"""
01489         self.check(b, a)
01490 
01491         b = """[i for i in xrange(10)]"""
01492         a = """[i for i in range(10)]"""
01493         self.check(b, a)

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