[Python-checkins] python/dist/src/Lib/test test_dis.py,NONE,1.1
montanaro@users.sourceforge.net
montanaro@users.sourceforge.net
Thu, 27 Feb 2003 13:27:11 -0800
- Previous message: [Python-checkins] python/dist/src/Lib BaseHTTPServer.py,1.24,1.25 UserList.py,1.17,1.18 atexit.py,1.5,1.6 bdb.py,1.41,1.42 cgi.py,1.75,1.76 copy.py,1.39,1.40 formatter.py,1.22,1.23 ihooks.py,1.15,1.16 imaplib.py,1.59,1.60 mhlib.py,1.34,1.35 mimify.py,1.21,1.22 modulefinder.py,1.4,1.5 nntplib.py,1.34,1.35 os.py,1.68,1.69 pdb.py,1.61,1.62 pre.py,1.13,1.14 profile.py,1.47,1.48 pstats.py,1.27,1.28 pty.py,1.14,1.15 pydoc.py,1.77,1.78 rexec.py,1.47,1.48 robotparser.py,1.16,1.17 sched.py,1.13,1.14 telnetlib.py,1.22,1.23 threading.py,1.31,1.32 tokenize.py,1.34,1.35 trace.py,1.2,1.3 unittest.py,1.21,1.22 urllib.py,1.153,1.154 xdrlib.py,1.14,1.15 xmllib.py,1.30,1.31 xmlrpclib.py,1.23,1.24
- Next message: [Python-checkins] python/dist/src/Lib opcode.py,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv29223
Added Files:
test_dis.py
Log Message:
simple test case for dis module
--- NEW FILE: test_dis.py ---
from test.test_support import verify, verbose, TestFailed, run_unittest
import sys
import dis
import StringIO
# Minimal tests for dis module
import unittest
# placement is crucial!!! move the start of _f and you have to adjust the
# line numbers in dis_f
def _f(a):
print a
return 1
dis_f = """\
13 0 LOAD_FAST 0 (a)
3 PRINT_ITEM
4 PRINT_NEWLINE
14 5 LOAD_CONST 1 (1)
8 RETURN_VALUE
9 LOAD_CONST 0 (None)
12 RETURN_VALUE
"""
class DisTests(unittest.TestCase):
def test_opmap(self):
self.assertEqual(dis.opmap["STOP_CODE"], 0)
self.assertEqual(dis.opmap["LOAD_CONST"] in dis.hasconst, True)
self.assertEqual(dis.opmap["STORE_NAME"] in dis.hasname, True)
def test_opname(self):
self.assertEqual(dis.opname[dis.opmap["LOAD_FAST"]], "LOAD_FAST")
def test_boundaries(self):
self.assertEqual(dis.opmap["EXTENDED_ARG"], dis.EXTENDED_ARG)
self.assertEqual(dis.opmap["STORE_NAME"], dis.HAVE_ARGUMENT)
def test_dis(self):
s = StringIO.StringIO()
save_stdout = sys.stdout
sys.stdout = s
dis.dis(_f)
sys.stdout = save_stdout
self.assertEqual(dis_f, s.getvalue())
def test_main():
run_unittest(DisTests)
if __name__ == "__main__":
test_main()
- Previous message: [Python-checkins] python/dist/src/Lib BaseHTTPServer.py,1.24,1.25 UserList.py,1.17,1.18 atexit.py,1.5,1.6 bdb.py,1.41,1.42 cgi.py,1.75,1.76 copy.py,1.39,1.40 formatter.py,1.22,1.23 ihooks.py,1.15,1.16 imaplib.py,1.59,1.60 mhlib.py,1.34,1.35 mimify.py,1.21,1.22 modulefinder.py,1.4,1.5 nntplib.py,1.34,1.35 os.py,1.68,1.69 pdb.py,1.61,1.62 pre.py,1.13,1.14 profile.py,1.47,1.48 pstats.py,1.27,1.28 pty.py,1.14,1.15 pydoc.py,1.77,1.78 rexec.py,1.47,1.48 robotparser.py,1.16,1.17 sched.py,1.13,1.14 telnetlib.py,1.22,1.23 threading.py,1.31,1.32 tokenize.py,1.34,1.35 trace.py,1.2,1.3 unittest.py,1.21,1.22 urllib.py,1.153,1.154 xdrlib.py,1.14,1.15 xmllib.py,1.30,1.31 xmlrpclib.py,1.23,1.24
- Next message: [Python-checkins] python/dist/src/Lib opcode.py,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]