Back to index

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

List of all members.

Public Member Functions

def test_operator_isCallable
def test_operator_sequenceIncludes
def test_operator_isSequenceType
def test_operator_isMappingType
def test_operator_isNumberType
def test_operator_repeat
def test_operator_irepeat
def test_bare_isCallable
def test_bare_sequenceIncludes
def test_bare_operator_isSequenceType
def test_bare_operator_isMappingType
def test_bare_operator_isNumberType
def test_bare_operator_repeat
def test_bare_operator_irepeat
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 = "operator"

Detailed Description

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

04408 
04409     def test_bare_isCallable(self):
04410         s = "isCallable(x)"
04411         t = "You should use 'hasattr(x, '__call__')' here."
04412         self.warns_unchanged(s, t)

Here is the call graph for this function:

Definition at line 4438 of file test_fixers.py.

04438 
04439     def test_bare_operator_irepeat(self):
04440         s = "irepeat(y, 187)"
04441         t = "You should use 'operator.imul(y, 187)' here."
04442         self.warns_unchanged(s, t)
04443 

Here is the call graph for this function:

Definition at line 4423 of file test_fixers.py.

04423 
04424     def test_bare_operator_isMappingType(self):
04425         s = "isMappingType(x)"
04426         t = "You should use 'isinstance(x, collections.Mapping)' here."
04427         self.warns_unchanged(s, t)

Here is the call graph for this function:

Definition at line 4428 of file test_fixers.py.

04428 
04429     def test_bare_operator_isNumberType(self):
04430         s = "isNumberType(y)"
04431         t = "You should use 'isinstance(y, numbers.Number)' here."
04432         self.warns_unchanged(s, t)

Here is the call graph for this function:

Definition at line 4418 of file test_fixers.py.

04418 
04419     def test_bare_operator_isSequenceType(self):
04420         s = "isSequenceType(z)"
04421         t = "You should use 'isinstance(z, collections.Sequence)' here."
04422         self.warns_unchanged(s, t)

Here is the call graph for this function:

Definition at line 4433 of file test_fixers.py.

04433 
04434     def test_bare_operator_repeat(self):
04435         s = "repeat(x, n)"
04436         t = "You should use 'operator.mul(x, n)' here."
04437         self.warns_unchanged(s, t)

Here is the call graph for this function:

Definition at line 4413 of file test_fixers.py.

04413 
04414     def test_bare_sequenceIncludes(self):
04415         s = "sequenceIncludes(x, y)"
04416         t = "You should use 'operator.contains(x, y)' here."
04417         self.warns_unchanged(s, t)

Here is the call graph for this function:

Definition at line 4395 of file test_fixers.py.

04395 
04396     def test_operator_irepeat(self):
04397         b = "operator.irepeat(x, n)"
04398         a = "operator.imul(x, n)"
04399         self.check(b, a)
04400 
04401         b = "operator .irepeat(x, n)"
04402         a = "operator .imul(x, n)"
04403         self.check(b, a)
04404 
04405         b = "operator.  irepeat(x, n)"
04406         a = "operator.  imul(x, n)"
04407         self.check(b, a)

Here is the call graph for this function:

Definition at line 4349 of file test_fixers.py.

04349 
04350     def test_operator_isCallable(self):
04351         b = "operator.isCallable(x)"
04352         a = "hasattr(x, '__call__')"
04353         self.check(b, a)

Here is the call graph for this function:

Definition at line 4372 of file test_fixers.py.

04372 
04373     def test_operator_isMappingType(self):
04374         b = "operator.isMappingType(x)"
04375         a = "import collections\nisinstance(x, collections.Mapping)"
04376         self.check(b, a)

Here is the call graph for this function:

Definition at line 4377 of file test_fixers.py.

04377 
04378     def test_operator_isNumberType(self):
04379         b = "operator.isNumberType(x)"
04380         a = "import numbers\nisinstance(x, numbers.Number)"
04381         self.check(b, a)

Here is the call graph for this function:

Definition at line 4367 of file test_fixers.py.

04367 
04368     def test_operator_isSequenceType(self):
04369         b = "operator.isSequenceType(x)"
04370         a = "import collections\nisinstance(x, collections.Sequence)"
04371         self.check(b, a)

Here is the call graph for this function:

Definition at line 4382 of file test_fixers.py.

04382 
04383     def test_operator_repeat(self):
04384         b = "operator.repeat(x, n)"
04385         a = "operator.mul(x, n)"
04386         self.check(b, a)
04387 
04388         b = "operator .repeat(x, n)"
04389         a = "operator .mul(x, n)"
04390         self.check(b, a)
04391 
04392         b = "operator.  repeat(x, n)"
04393         a = "operator.  mul(x, n)"
04394         self.check(b, a)

Here is the call graph for this function:

Definition at line 4354 of file test_fixers.py.

04354 
04355     def test_operator_sequenceIncludes(self):
04356         b = "operator.sequenceIncludes(x, y)"
04357         a = "operator.contains(x, y)"
04358         self.check(b, a)
04359 
04360         b = "operator .sequenceIncludes(x, y)"
04361         a = "operator .contains(x, y)"
04362         self.check(b, a)
04363 
04364         b = "operator.  sequenceIncludes(x, y)"
04365         a = "operator.  contains(x, y)"
04366         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 4347 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: