forked from ludwigschwardt/python-gnureadline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
31 lines (25 loc) · 919 Bytes
/
test.py
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
import sys
from os import path
def test_import_new():
"""import gnureadline without touching sys.path"""
import gnureadline
def test_import():
"""A very basic unittest; can we 'import readline'?"""
msg = r'''
readline.so was not installed properly into site-packages.
'import readline' imports %s
sys.path:\n%s'''
# Put site-packages in front of sys.path so we don't end up importing the global
# readline.so
save_sys_path = list(sys.path)
sys.path = (
[p for p in sys.path if 'site-packages' in p] + \
[p for p in sys.path if 'site-packages' not in p])
import readline
try:
assert 'site-packages' in path.dirname(readline.__file__), \
msg % (readline.__file__, '\n'.join(sys.path))
finally:
sys.path = save_sys_path
import gnureadline
assert readline.parse_and_bind is gnureadline.parse_and_bind