Back to index

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

List of all members.

Public Member Functions

def test_simple
def test_names_import
def test_complex_expression
def test_comments
def test_in_a_function
def test_no_sys_import
def test_unchanged
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 = "exitfunc"

Detailed Description

Definition at line 4444 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:

Here is the caller 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 4483 of file test_fixers.py.

04483 
04484     def test_comments(self):
04485         b = """
04486             import sys # Foo
04487             sys.exitfunc = f # Blah
04488             """
04489         a = """
04490             import sys
04491             import atexit # Foo
04492             atexit.register(f) # Blah
04493             """
04494         self.check(b, a)
04495 
04496         b = """
04497             import apples, sys, crumbs, larry # Pleasant comments
04498             sys.exitfunc = func
04499             """
04500         a = """
04501             import apples, sys, crumbs, larry, atexit # Pleasant comments
04502             atexit.register(func)
04503             """
04504         self.check(b, a)

Here is the call graph for this function:

Definition at line 4471 of file test_fixers.py.

04471 
04472     def test_complex_expression(self):
04473         b = """
04474             import sys
04475             sys.exitfunc = do(d)/a()+complex(f=23, g=23)*expression
04476             """
04477         a = """
04478             import sys
04479             import atexit
04480             atexit.register(do(d)/a()+complex(f=23, g=23)*expression)
04481             """
04482         self.check(b, a)

Here is the call graph for this function:

Definition at line 4505 of file test_fixers.py.

04505 
04506     def test_in_a_function(self):
04507         b = """
04508             import sys
04509             def f():
04510                 sys.exitfunc = func
04511             """
04512         a = """
04513             import sys
04514             import atexit
04515             def f():
04516                 atexit.register(func)
04517              """
04518         self.check(b, a)

Here is the call graph for this function:

Definition at line 4460 of file test_fixers.py.

04460 
04461     def test_names_import(self):
04462         b = """
04463             import sys, crumbs
04464             sys.exitfunc = my_func
04465             """
04466         a = """
04467             import sys, crumbs, atexit
04468             atexit.register(my_func)
04469             """
04470         self.check(b, a)

Here is the call graph for this function:

Definition at line 4519 of file test_fixers.py.

04519 
04520     def test_no_sys_import(self):
04521         b = """sys.exitfunc = f"""
04522         a = """atexit.register(f)"""
04523         msg = ("Can't find sys import; Please add an atexit import at the "
04524             "top of your file.")
04525         self.warns(b, a, msg)
04526 

Here is the call graph for this function:

Definition at line 4448 of file test_fixers.py.

04448 
04449     def test_simple(self):
04450         b = """
04451             import sys
04452             sys.exitfunc = my_atexit
04453             """
04454         a = """
04455             import sys
04456             import atexit
04457             atexit.register(my_atexit)
04458             """
04459         self.check(b, a)

Here is the call graph for this function:

Definition at line 4527 of file test_fixers.py.

04527 
04528     def test_unchanged(self):
04529         s = """f(sys.exitfunc)"""
04530         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 4446 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: