##// END OF EJS Templates
Merge pull request #1377 from takluyver/i1375...
Min RK -
r6122:fd42bee9 merge
parent child Browse files
Show More
@@ -15,6 +15,7 b' from __future__ import print_function'
15 # Stdlib imports
15 # Stdlib imports
16 import atexit
16 import atexit
17 import datetime
17 import datetime
18 from io import open as io_open
18 import os
19 import os
19 import re
20 import re
20 try:
21 try:
@@ -808,7 +809,7 b" def magic_history(self, parameter_s = ''):"
808 print('Aborting.')
809 print('Aborting.')
809 return
810 return
810 print("Overwriting file.")
811 print("Overwriting file.")
811 outfile = open(outfname,'w')
812 outfile = io_open(outfname, 'w', encoding='utf-8')
812 close_at_end = True
813 close_at_end = True
813
814
814 print_nums = 'n' in opts
815 print_nums = 'n' in opts
@@ -851,10 +852,10 b" def magic_history(self, parameter_s = ''):"
851 multiline = "\n" in inline
852 multiline = "\n" in inline
852 line_sep = '\n' if multiline else ' '
853 line_sep = '\n' if multiline else ' '
853 if print_nums:
854 if print_nums:
854 print('%s:%s' % (_format_lineno(session, lineno).rjust(width),
855 print(u'%s:%s' % (_format_lineno(session, lineno).rjust(width),
855 line_sep), file=outfile, end='')
856 line_sep), file=outfile, end=u'')
856 if pyprompts:
857 if pyprompts:
857 print(">>> ", end="", file=outfile)
858 print(u">>> ", end=u"", file=outfile)
858 if multiline:
859 if multiline:
859 inline = "\n... ".join(inline.splitlines()) + "\n..."
860 inline = "\n... ".join(inline.splitlines()) + "\n..."
860 print(inline, file=outfile)
861 print(inline, file=outfile)
@@ -7,6 +7,7 b''
7
7
8 # stdlib
8 # stdlib
9 import os
9 import os
10 import shutil
10 import sys
11 import sys
11 import tempfile
12 import tempfile
12 import unittest
13 import unittest
@@ -31,7 +32,7 b' def test_history():'
31 hist_file = os.path.join(tmpdir, 'history.sqlite')
32 hist_file = os.path.join(tmpdir, 'history.sqlite')
32 try:
33 try:
33 ip.history_manager = HistoryManager(shell=ip, hist_file=hist_file)
34 ip.history_manager = HistoryManager(shell=ip, hist_file=hist_file)
34 hist = ['a=1', 'def f():\n test = 1\n return test', u"b='€Æ¾÷ß'"]
35 hist = [u'a=1', u'def f():\n test = 1\n return test', u"b='€Æ¾÷ß'"]
35 for i, h in enumerate(hist, start=1):
36 for i, h in enumerate(hist, start=1):
36 ip.history_manager.store_inputs(i, h)
37 ip.history_manager.store_inputs(i, h)
37
38
@@ -51,6 +52,12 b' def test_history():'
51 # Check whether specifying a range beyond the end of the current
52 # Check whether specifying a range beyond the end of the current
52 # session results in an error (gh-804)
53 # session results in an error (gh-804)
53 ip.magic('%hist 2-500')
54 ip.magic('%hist 2-500')
55
56 # Check that we can write non-ascii characters to a file
57 ip.magic("%%hist -f %s" % os.path.join(tmpdir, "test1"))
58 ip.magic("%%hist -pf %s" % os.path.join(tmpdir, "test2"))
59 ip.magic("%%hist -nf %s" % os.path.join(tmpdir, "test3"))
60 ip.magic("%%save %s 1-10" % os.path.join(tmpdir, "test4"))
54
61
55 # New session
62 # New session
56 ip.history_manager.reset()
63 ip.history_manager.reset()
General Comments 0
You need to be logged in to leave comments. Login now