Back to index

python3.2  3.2.2
Public Member Functions
test.test_dis.DisTests Class Reference

List of all members.

Public Member Functions

def do_disassembly_test
def test_opmap
def test_opname
def test_boundaries
def test_dis
def test_bug_708901
def test_bug_1333982
def test_big_linenos
def test_big_linenos
def test_disassemble_str

Detailed Description

Definition at line 140 of file test_dis.py.


Member Function Documentation

def test.test_dis.DisTests.do_disassembly_test (   self,
  func,
  expected 
)

Definition at line 141 of file test_dis.py.

00141 
00142     def do_disassembly_test(self, func, expected):
00143         s = io.StringIO()
00144         save_stdout = sys.stdout
00145         sys.stdout = s
00146         dis.dis(func)
00147         sys.stdout = save_stdout
00148         got = s.getvalue()
00149         # Trim trailing blanks (if any).
00150         lines = got.split('\n')
00151         lines = [line.rstrip() for line in lines]
00152         expected = expected.split("\n")
00153         import difflib
00154         if expected != lines:
00155             self.fail(
00156                 "events did not match expectation:\n" +
00157                 "\n".join(difflib.ndiff(expected,
00158                                         lines)))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 188 of file test_dis.py.

00188 
00189     def test_big_linenos(self):
00190         def func(count):
00191             namespace = {}
00192             func = "def foo():\n " + "".join(["\n "] * count + ["spam\n"])
00193             exec(func, namespace)
00194             return namespace['foo']
00195 
00196         # Test all small ranges
00197         for i in range(1, 300):
00198             expected = _BIG_LINENO_FORMAT % (i + 2)
00199             self.do_disassembly_test(func(i), expected)
00200 
00201         # Test some larger ranges too
00202         for i in range(300, 5000, 10):
00203             expected = _BIG_LINENO_FORMAT % (i + 2)
00204             self.do_disassembly_test(func(i), expected)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 205 of file test_dis.py.

00205 
00206     def test_big_linenos(self):
00207         from test import dis_module
00208         self.do_disassembly_test(dis_module, dis_module_expected_results)

Here is the call graph for this function:

Definition at line 167 of file test_dis.py.

00167 
00168     def test_boundaries(self):
00169         self.assertEqual(dis.opmap["EXTENDED_ARG"], dis.EXTENDED_ARG)
00170         self.assertEqual(dis.opmap["STORE_NAME"], dis.HAVE_ARGUMENT)

Here is the call graph for this function:

Definition at line 177 of file test_dis.py.

00177 
00178     def test_bug_1333982(self):
00179         # XXX: re-enable this test!
00180         # This one is checking bytecodes generated for an `assert` statement,
00181         # so fails if the tests are run with -O.  Skip this test then.
00182         pass # Test has been disabled due to change in the way
00183              # list comps are handled. The byte code now includes
00184              # a memory address and a file location, so they change from
00185              # run to run.
00186         # if __debug__:
00187         #    self.do_disassembly_test(bug1333982, dis_bug1333982)

Definition at line 174 of file test_dis.py.

00174 
00175     def test_bug_708901(self):
00176         self.do_disassembly_test(bug708901, dis_bug708901)

Here is the call graph for this function:

Definition at line 171 of file test_dis.py.

00171 
00172     def test_dis(self):
00173         self.do_disassembly_test(_f, dis_f)

Here is the call graph for this function:

Definition at line 209 of file test_dis.py.

00209 
00210     def test_disassemble_str(self):
00211         self.do_disassembly_test(expr_str, dis_expr_str)
00212         self.do_disassembly_test(simple_stmt_str, dis_simple_stmt_str)
00213         self.do_disassembly_test(compound_stmt_str, dis_compound_stmt_str)

Here is the call graph for this function:

Definition at line 159 of file test_dis.py.

00159 
00160     def test_opmap(self):
00161         self.assertEqual(dis.opmap["STOP_CODE"], 0)
00162         self.assertIn(dis.opmap["LOAD_CONST"], dis.hasconst)
00163         self.assertIn(dis.opmap["STORE_NAME"], dis.hasname)

Here is the call graph for this function:

Definition at line 164 of file test_dis.py.

00164 
00165     def test_opname(self):
00166         self.assertEqual(dis.opname[dis.opmap["LOAD_FAST"]], "LOAD_FAST")

Here is the call graph for this function:


The documentation for this class was generated from the following file: