Show More
@@ -1,11 +1,16 b'' | |||
|
1 | #!/usr/bin/env python | |
|
1 | 2 | # coding: utf-8 |
|
2 | 3 | """These tests have to be run separately from the main test suite (iptest), |
|
3 | 4 | because that sets the default encoding to utf-8, and it cannot be changed after |
|
4 | 5 | the interpreter is up and running. The default encoding in a Python 2.x |
|
5 | 6 | environment is ASCII.""" |
|
6 |
import unittest |
|
|
7 | import unittest | |
|
8 | import sys, os.path | |
|
7 | 9 | |
|
10 | from IPython.core import ipapi | |
|
8 | 11 | from IPython.core import compilerop |
|
12 | from IPython.core.history import HistoryManager | |
|
13 | from IPython.utils.tempdir import TemporaryDirectory | |
|
9 | 14 | |
|
10 | 15 | assert sys.getdefaultencoding() == "ascii" |
|
11 | 16 | |
@@ -13,6 +18,34 b' class CompileropTest(unittest.TestCase):' | |||
|
13 | 18 | def test_accept_unicode(self): |
|
14 | 19 | cp = compilerop.CachingCompiler() |
|
15 | 20 | cp(u"t = 'žćčšđ'", "single") |
|
21 | ||
|
22 | class HistoryTest(unittest.TestCase): | |
|
23 | def test_reload_unicode(self): | |
|
24 | ip = ipapi.get() | |
|
25 | with TemporaryDirectory() as tmpdir: | |
|
26 | histfile = os.path.realpath(os.path.join(tmpdir, 'history.json')) | |
|
27 | # Ensure that we restore the history management that we mess with in | |
|
28 | # this test doesn't affect the IPython instance used by the test suite | |
|
29 | # beyond this test. | |
|
30 | hist_manager_ori = ip.history_manager | |
|
31 | try: | |
|
32 | ip.history_manager = HistoryManager(ip) | |
|
33 | ip.history_manager.hist_file = histfile | |
|
34 | print 'test',histfile | |
|
35 | hist = [u"t = 'žćčšđ'"] | |
|
36 | # test save and load | |
|
37 | ip.history_manager.input_hist_raw[:] = [] | |
|
38 | for h in hist: | |
|
39 | ip.history_manager.input_hist_raw.append(h) | |
|
40 | ip.save_history() | |
|
41 | ip.history_manager.input_hist_raw[:] = [] | |
|
42 | ip.reload_history() | |
|
43 | self.assert_equal(len(ip.history_manager.input_hist_raw), len(hist)) | |
|
44 | for i,h in enumerate(hist): | |
|
45 | nt.assert_equal(hist[i], ip.history_manager.input_hist_raw[i]) | |
|
46 | finally: | |
|
47 | # Restore history manager | |
|
48 | ip.history_manager = hist_manager_ori | |
|
16 | 49 | |
|
17 | 50 | if __name__ == "__main__": |
|
18 | 51 | unittest.main() |
General Comments 0
You need to be logged in to leave comments.
Login now