Back to index

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

List of all members.

Public Member Functions

def test_basic
def test_listcomps
def test_whitespace
def test_comments
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 = "set_literal"

Detailed Description

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

03904 
03905     def test_basic(self):
03906         b = """set([1, 2, 3])"""
03907         a = """{1, 2, 3}"""
03908         self.check(b, a)
03909 
03910         b = """set((1, 2, 3))"""
03911         a = """{1, 2, 3}"""
03912         self.check(b, a)
03913 
03914         b = """set((1,))"""
03915         a = """{1}"""
03916         self.check(b, a)
03917 
03918         b = """set([1])"""
03919         self.check(b, a)
03920 
03921         b = """set((a, b))"""
03922         a = """{a, b}"""
03923         self.check(b, a)
03924 
03925         b = """set([a, b])"""
03926         self.check(b, a)
03927 
03928         b = """set((a*234, f(args=23)))"""
03929         a = """{a*234, f(args=23)}"""
03930         self.check(b, a)
03931 
03932         b = """set([a*23, f(23)])"""
03933         a = """{a*23, f(23)}"""
03934         self.check(b, a)
03935 
03936         b = """set([a-234**23])"""
03937         a = """{a-234**23}"""
03938         self.check(b, a)

Here is the call graph for this function:

Definition at line 3988 of file test_fixers.py.

03988 
03989     def test_comments(self):
03990         b = """set((1, 2)) # Hi"""
03991         a = """{1, 2} # Hi"""
03992         self.check(b, a)
03993 
03994         # This isn't optimal behavior, but the fixer is optional.
03995         b = """
03996             # Foo
03997             set( # Bar
03998                (1, 2)
03999             )
04000             """
04001         a = """
04002             # Foo
04003             {1, 2}
04004             """
04005         self.check(b, a)

Here is the call graph for this function:

Definition at line 3939 of file test_fixers.py.

03939 
03940     def test_listcomps(self):
03941         b = """set([x for x in y])"""
03942         a = """{x for x in y}"""
03943         self.check(b, a)
03944 
03945         b = """set([x for x in y if x == m])"""
03946         a = """{x for x in y if x == m}"""
03947         self.check(b, a)
03948 
03949         b = """set([x for x in y for a in b])"""
03950         a = """{x for x in y for a in b}"""
03951         self.check(b, a)
03952 
03953         b = """set([f(x) - 23 for x in y])"""
03954         a = """{f(x) - 23 for x in y}"""
03955         self.check(b, a)

Here is the call graph for this function:

Definition at line 4006 of file test_fixers.py.

04006 
04007     def test_unchanged(self):
04008         s = """set()"""
04009         self.unchanged(s)
04010 
04011         s = """set(a)"""
04012         self.unchanged(s)
04013 
04014         s = """set(a, b, c)"""
04015         self.unchanged(s)
04016 
04017         # Don't transform generators because they might have to be lazy.
04018         s = """set(x for x in y)"""
04019         self.unchanged(s)
04020 
04021         s = """set(x for x in y if z)"""
04022         self.unchanged(s)
04023 
04024         s = """set(a*823-23**2 + f(23))"""
04025         self.unchanged(s)
04026 

Here is the call graph for this function:

Definition at line 3956 of file test_fixers.py.

03956 
03957     def test_whitespace(self):
03958         b = """set( [1, 2])"""
03959         a = """{1, 2}"""
03960         self.check(b, a)
03961 
03962         b = """set([1 ,  2])"""
03963         a = """{1 ,  2}"""
03964         self.check(b, a)
03965 
03966         b = """set([ 1 ])"""
03967         a = """{ 1 }"""
03968         self.check(b, a)
03969 
03970         b = """set( [1] )"""
03971         a = """{1}"""
03972         self.check(b, a)
03973 
03974         b = """set([  1,  2  ])"""
03975         a = """{  1,  2  }"""
03976         self.check(b, a)
03977 
03978         b = """set([x  for x in y ])"""
03979         a = """{x  for x in y }"""
03980         self.check(b, a)
03981 
03982         b = """set(
03983                    [1, 2]
03984                )
03985             """
03986         a = """{1, 2}\n"""
03987         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 3902 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: