-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_pydev_ipython.py
More file actions
74 lines (59 loc) · 2.59 KB
/
test_pydev_ipython.py
File metadata and controls
74 lines (59 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import unittest
import sys
import os
#make it as if we were executing from the directory above this one
sys.argv[0] = os.path.dirname(sys.argv[0])
#twice the dirname to get the previous level from this file.
sys.path.insert(1, os.path.join(os.path.dirname(sys.argv[0])))
IS_JYTHON = sys.platform.find('java') != -1
#=======================================================================================================================
# TestCase
#=======================================================================================================================
class TestCase(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
def tearDown(self):
unittest.TestCase.tearDown(self)
def testIPython(self):
try:
from pydev_ipython_console import PyDevFrontEnd
except:
if IS_JYTHON:
return
front_end = PyDevFrontEnd()
front_end.input_buffer = 'if True:'
self.assert_(not front_end._on_enter())
front_end.input_buffer = 'if True:\n' + \
front_end.continuation_prompt()+' a = 10\n'
self.assert_(not front_end._on_enter())
front_end.input_buffer = 'if True:\n' + \
front_end.continuation_prompt()+' a = 10\n\n'
self.assert_(front_end._on_enter())
# front_end.input_buffer = ' print a'
# self.assert_(not front_end._on_enter())
# front_end.input_buffer = ''
# self.assert_(front_end._on_enter())
# front_end.input_buffer = 'a.'
# front_end.complete_current_input()
# front_end.input_buffer = 'if True:'
# front_end._on_enter()
front_end.input_buffer = 'a = 30'
front_end._on_enter()
front_end.input_buffer = 'print a'
front_end._on_enter()
front_end.input_buffer = 'a?'
front_end._on_enter()
print front_end.complete('%')
print front_end.complete('%e')
print front_end.complete('cd c:/t')
print front_end.complete('cd c:/temp/')
# front_end.input_buffer = 'print raw_input("press enter\\n")'
# front_end._on_enter()
#
#=======================================================================================================================
# main
#=======================================================================================================================
if __name__ == '__main__':
if sys.platform.find('java') != -1:
#IPython not available for Jython
unittest.main()