]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/wx/py/tests/test_interpreter.py
Docstring tweaks
[wxWidgets.git] / wxPython / wx / py / tests / test_interpreter.py
... / ...
CommitLineData
1#!/usr/bin/env python
2
3__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
4__cvsid__ = "$Id$"
5__revision__ = "$Revision$"[11:-2]
6
7import unittest
8
9# Import from this module's parent directory.
10import os
11import sys
12sys.path.insert(0, os.pardir)
13import interpreter
14del sys.path[0]
15del sys
16del os
17
18
19"""
20These unittest methods are preferred:
21-------------------------------------
22self.assert_(expr, msg=None)
23self.assertEqual(first, second, msg=None)
24self.assertRaises(excClass, callableObj, *args, **kwargs)
25self.fail(msg=None)
26self.failIf(expr, msg=None)
27"""
28
29
30class ModuleTestCase(unittest.TestCase):
31
32 def test_module(self):
33 module = interpreter
34 self.assert_(module.__author__)
35 self.assert_(module.__cvsid__)
36 self.assert_(module.__revision__)
37 self.assert_(module.Interpreter)
38 self.assert_(module.Interpreter.push)
39 self.assert_(module.Interpreter.runsource)
40 self.assert_(module.Interpreter.getAutoCompleteList)
41 self.assert_(module.Interpreter.getCallTip)
42 self.assert_(module.InterpreterAlaCarte)
43
44
45class InterpreterTestCase(unittest.TestCase):
46
47 def setUp(self):
48 self.output = ''
49 self.i = interpreter.Interpreter(stdout=self)
50
51 def write(self, text):
52 """Capture output from self.i.push()."""
53 self.output += text
54
55 def tearDown(self):
56 self.output = ''
57 self.i = None
58 del self.i
59
60 def test_more(self):
61 self.assertEqual(self.i.push('dir()'), 0)
62 self.assertEqual(self.i.push('for n in range(3):'), 1)
63
64 def test_push(self):
65 values = (
66 ('dir', '<built-in function dir>'),
67 ('dir()', "['__builtins__', '__doc__', '__name__']"),
68 ('2 + 2', '4'),
69 ('d = {}', ''),
70 ('d', '{}'),
71 ('del d', ''),
72 ('len([4,5,6])', '3'),
73 )
74 for input, output in values:
75 if output: output += '\n'
76 self.i.push(input)
77 self.assertEqual(self.output, output)
78 self.output = ''
79
80
81if __name__ == '__main__':
82 unittest.main()