Back to index

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

List of all members.

Public Member Functions

def test_prefix_preservation
def test_simple
def test_simple_no_space_before_target
def test_tuple_unpack
def test_multi_class
def test_list_unpack
def test_weird_target_1
def test_weird_target_2
def test_weird_target_3
def test_bare_except
def test_bare_except_and_else_finally
def test_multi_fixed_excepts_before_bare_except
def test_one_line_suites
def test_unchanged_1
def test_unchanged_2
def test_unchanged_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 = "except"

Detailed Description

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

00701 
00702     def test_bare_except(self):
00703         b = """
00704             try:
00705                 pass
00706             except Exception, a:
00707                 pass
00708             except:
00709                 pass"""
00710 
00711         a = """
00712             try:
00713                 pass
00714             except Exception as a:
00715                 pass
00716             except:
00717                 pass"""
00718         self.check(b, a)

Here is the call graph for this function:

Definition at line 719 of file test_fixers.py.

00719 
00720     def test_bare_except_and_else_finally(self):
00721         b = """
00722             try:
00723                 pass
00724             except Exception, a:
00725                 pass
00726             except:
00727                 pass
00728             else:
00729                 pass
00730             finally:
00731                 pass"""
00732 
00733         a = """
00734             try:
00735                 pass
00736             except Exception as a:
00737                 pass
00738             except:
00739                 pass
00740             else:
00741                 pass
00742             finally:
00743                 pass"""
00744         self.check(b, a)

Here is the call graph for this function:

Definition at line 641 of file test_fixers.py.

00641 
00642     def test_list_unpack(self):
00643         b = """
00644             try:
00645                 pass
00646             except Exception, [a, b]:
00647                 pass"""
00648 
00649         a = """
00650             try:
00651                 pass
00652             except Exception as xxx_todo_changeme:
00653                 [a, b] = xxx_todo_changeme.args
00654                 pass"""
00655         self.check(b, a)

Here is the call graph for this function:

Definition at line 627 of file test_fixers.py.

00627 
00628     def test_multi_class(self):
00629         b = """
00630             try:
00631                 pass
00632             except (RuntimeError, ImportError), e:
00633                 pass"""
00634 
00635         a = """
00636             try:
00637                 pass
00638             except (RuntimeError, ImportError) as e:
00639                 pass"""
00640         self.check(b, a)

Here is the call graph for this function:

Definition at line 745 of file test_fixers.py.

00745 
00746     def test_multi_fixed_excepts_before_bare_except(self):
00747         b = """
00748             try:
00749                 pass
00750             except TypeError, b:
00751                 pass
00752             except Exception, a:
00753                 pass
00754             except:
00755                 pass"""
00756 
00757         a = """
00758             try:
00759                 pass
00760             except TypeError as b:
00761                 pass
00762             except Exception as a:
00763                 pass
00764             except:
00765                 pass"""
00766         self.check(b, a)

Here is the call graph for this function:

Definition at line 767 of file test_fixers.py.

00767 
00768     def test_one_line_suites(self):
00769         b = """
00770             try: raise TypeError
00771             except TypeError, e:
00772                 pass
00773             """
00774         a = """
00775             try: raise TypeError
00776             except TypeError as e:
00777                 pass
00778             """
00779         self.check(b, a)
00780         b = """
00781             try:
00782                 raise TypeError
00783             except TypeError, e: pass
00784             """
00785         a = """
00786             try:
00787                 raise TypeError
00788             except TypeError as e: pass
00789             """
00790         self.check(b, a)
00791         b = """
00792             try: raise TypeError
00793             except TypeError, e: pass
00794             """
00795         a = """
00796             try: raise TypeError
00797             except TypeError as e: pass
00798             """
00799         self.check(b, a)
00800         b = """
00801             try: raise TypeError
00802             except TypeError, e: pass
00803             else: function()
00804             finally: done()
00805             """
00806         a = """
00807             try: raise TypeError
00808             except TypeError as e: pass
00809             else: function()
00810             finally: done()
00811             """
00812         self.check(b, a)

Here is the call graph for this function:

Definition at line 567 of file test_fixers.py.

00567 
00568     def test_prefix_preservation(self):
00569         b = """
00570             try:
00571                 pass
00572             except (RuntimeError, ImportError),    e:
00573                 pass"""
00574         a = """
00575             try:
00576                 pass
00577             except (RuntimeError, ImportError) as    e:
00578                 pass"""
00579         self.check(b, a)

Here is the call graph for this function:

Definition at line 580 of file test_fixers.py.

00580 
00581     def test_simple(self):
00582         b = """
00583             try:
00584                 pass
00585             except Foo, e:
00586                 pass"""
00587         a = """
00588             try:
00589                 pass
00590             except Foo as e:
00591                 pass"""
00592         self.check(b, a)

Here is the call graph for this function:

Definition at line 593 of file test_fixers.py.

00593 
00594     def test_simple_no_space_before_target(self):
00595         b = """
00596             try:
00597                 pass
00598             except Foo,e:
00599                 pass"""
00600         a = """
00601             try:
00602                 pass
00603             except Foo as e:
00604                 pass"""
00605         self.check(b, a)

Here is the call graph for this function:

Definition at line 606 of file test_fixers.py.

00606 
00607     def test_tuple_unpack(self):
00608         b = """
00609             def foo():
00610                 try:
00611                     pass
00612                 except Exception, (f, e):
00613                     pass
00614                 except ImportError, e:
00615                     pass"""
00616 
00617         a = """
00618             def foo():
00619                 try:
00620                     pass
00621                 except Exception as xxx_todo_changeme:
00622                     (f, e) = xxx_todo_changeme.args
00623                     pass
00624                 except ImportError as e:
00625                     pass"""
00626         self.check(b, a)

Here is the call graph for this function:

Definition at line 815 of file test_fixers.py.

00815 
00816     def test_unchanged_1(self):
00817         s = """
00818             try:
00819                 pass
00820             except:
00821                 pass"""
00822         self.unchanged(s)

Here is the call graph for this function:

Definition at line 823 of file test_fixers.py.

00823 
00824     def test_unchanged_2(self):
00825         s = """
00826             try:
00827                 pass
00828             except Exception:
00829                 pass"""
00830         self.unchanged(s)

Here is the call graph for this function:

Definition at line 831 of file test_fixers.py.

00831 
00832     def test_unchanged_3(self):
00833         s = """
00834             try:
00835                 pass
00836             except (Exception, SystemExit):
00837                 pass"""
00838         self.unchanged(s)

Here is the call graph for this function:

Definition at line 656 of file test_fixers.py.

00656 
00657     def test_weird_target_1(self):
00658         b = """
00659             try:
00660                 pass
00661             except Exception, d[5]:
00662                 pass"""
00663 
00664         a = """
00665             try:
00666                 pass
00667             except Exception as xxx_todo_changeme:
00668                 d[5] = xxx_todo_changeme
00669                 pass"""
00670         self.check(b, a)

Here is the call graph for this function:

Definition at line 671 of file test_fixers.py.

00671 
00672     def test_weird_target_2(self):
00673         b = """
00674             try:
00675                 pass
00676             except Exception, a.foo:
00677                 pass"""
00678 
00679         a = """
00680             try:
00681                 pass
00682             except Exception as xxx_todo_changeme:
00683                 a.foo = xxx_todo_changeme
00684                 pass"""
00685         self.check(b, a)

Here is the call graph for this function:

Definition at line 686 of file test_fixers.py.

00686 
00687     def test_weird_target_3(self):
00688         b = """
00689             try:
00690                 pass
00691             except Exception, a().foo:
00692                 pass"""
00693 
00694         a = """
00695             try:
00696                 pass
00697             except Exception as xxx_todo_changeme:
00698                 a().foo = xxx_todo_changeme
00699                 pass"""
00700         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 565 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: