Back to index

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

List of all members.

Public Member Functions

def test_prefix_preservation
def test_idempotency
def test_idempotency_print_as_function
def test_1
def test_2
def test_3
def test_4
def test_5
def test_tuple
def test_trailing_comma_1
def test_trailing_comma_2
def test_trailing_comma_3
def test_vargs_without_trailing_comma
def test_with_trailing_comma
def test_no_trailing_comma
def test_spaces_before_file
def test_with_future_print_function
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 = "print"

Detailed Description

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

00395 
00396     def test_1(self):
00397         b = """print 1, 1+1, 1+1+1"""
00398         a = """print(1, 1+1, 1+1+1)"""
00399         self.check(b, a)

Here is the call graph for this function:

Definition at line 400 of file test_fixers.py.

00400 
00401     def test_2(self):
00402         b = """print 1, 2"""
00403         a = """print(1, 2)"""
00404         self.check(b, a)

Here is the call graph for this function:

Definition at line 405 of file test_fixers.py.

00405 
00406     def test_3(self):
00407         b = """print"""
00408         a = """print()"""
00409         self.check(b, a)

Here is the call graph for this function:

Definition at line 410 of file test_fixers.py.

00410 
00411     def test_4(self):
00412         # from bug 3000
00413         b = """print whatever; print"""
00414         a = """print(whatever); print()"""
00415         self.check(b, a)

Here is the call graph for this function:

Definition at line 416 of file test_fixers.py.

00416 
00417     def test_5(self):
00418         b = """print; print whatever;"""
00419         a = """print(); print(whatever);"""
00420         self.check(b, a)

Here is the call graph for this function:

Definition at line 377 of file test_fixers.py.

00377 
00378     def test_idempotency(self):
00379         s = """print()"""
00380         self.unchanged(s)
00381 
00382         s = """print('')"""
00383         self.unchanged(s)

Here is the call graph for this function:

Definition at line 384 of file test_fixers.py.

00384 
00385     def test_idempotency_print_as_function(self):
00386         self.refactor.driver.grammar = pygram.python_grammar_no_print_statement
00387         s = """print(1, 1+1, 1+1+1)"""
00388         self.unchanged(s)
00389 
00390         s = """print()"""
00391         self.unchanged(s)
00392 
00393         s = """print('')"""
00394         self.unchanged(s)

Here is the call graph for this function:

Definition at line 455 of file test_fixers.py.

00455 
00456     def test_no_trailing_comma(self):
00457         b = """print >>sys.stderr, 1+1"""
00458         a = """print(1+1, file=sys.stderr)"""
00459         self.check(b, a)

Here is the call graph for this function:

Definition at line 372 of file test_fixers.py.

00372 
00373     def test_prefix_preservation(self):
00374         b = """print 1,   1+1,   1+1+1"""
00375         a = """print(1,   1+1,   1+1+1)"""
00376         self.check(b, a)

Here is the call graph for this function:

Definition at line 460 of file test_fixers.py.

00460 
00461     def test_spaces_before_file(self):
00462         b = """print >>  sys.stderr"""
00463         a = """print(file=sys.stderr)"""
00464         self.check(b, a)

Here is the call graph for this function:

Definition at line 428 of file test_fixers.py.

00428 
00429     def test_trailing_comma_1(self):
00430         b = """print 1, 2, 3,"""
00431         a = """print(1, 2, 3, end=' ')"""
00432         self.check(b, a)

Here is the call graph for this function:

Definition at line 433 of file test_fixers.py.

00433 
00434     def test_trailing_comma_2(self):
00435         b = """print 1, 2,"""
00436         a = """print(1, 2, end=' ')"""
00437         self.check(b, a)

Here is the call graph for this function:

Definition at line 438 of file test_fixers.py.

00438 
00439     def test_trailing_comma_3(self):
00440         b = """print 1,"""
00441         a = """print(1, end=' ')"""
00442         self.check(b, a)

Here is the call graph for this function:

Definition at line 421 of file test_fixers.py.

00421 
00422     def test_tuple(self):
00423         b = """print (a, b, c)"""
00424         a = """print((a, b, c))"""
00425         self.check(b, a)

Here is the call graph for this function:

Definition at line 445 of file test_fixers.py.

00445 
00446     def test_vargs_without_trailing_comma(self):
00447         b = """print >>sys.stderr, 1, 2, 3"""
00448         a = """print(1, 2, 3, file=sys.stderr)"""
00449         self.check(b, a)

Here is the call graph for this function:

Definition at line 465 of file test_fixers.py.

00465 
00466     def test_with_future_print_function(self):
00467         s = "from __future__ import print_function\n" \
00468             "print('Hai!', end=' ')"
00469         self.unchanged(s)
00470 
00471         b = "print 'Hello, world!'"
00472         a = "print('Hello, world!')"
00473         self.check(b, a)
00474 

Here is the call graph for this function:

Definition at line 450 of file test_fixers.py.

00450 
00451     def test_with_trailing_comma(self):
00452         b = """print >>sys.stderr, 1, 2,"""
00453         a = """print(1, 2, end=' ', file=sys.stderr)"""
00454         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 370 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: