# coding: utf-8
"""These tests have to be run separately from the main test suite (iptest),
because that sets the default encoding to utf-8, and it cannot be changed after
the interpreter is up and running. The default encoding in a Python 2.x 
environment is ASCII."""
import unittest, sys

from IPython.core import compilerop

assert sys.getdefaultencoding() == "ascii"

class CompileropTest(unittest.TestCase):
    def test_accept_unicode(self):
        cp = compilerop.CachingCompiler()
        cp(u"t = 'žćčšđ'", "single")

if __name__ == "__main__":
    unittest.main()

@@ -1,8 +1,30 @@
+#!/usr/bin/env python%0A
 # coding
@@ -304,13 +304,28 @@
 test
-, sys
+%0Aimport sys, os.path
 %0A%0Afr
@@ -347,26 +347,158 @@
  import 
-compilerop
+ipapi%0Afrom IPython.core import compilerop%0Afrom IPython.core.history import HistoryManager%0Afrom IPython.utils.tempdir import TemporaryDirectory
 %0A%0Aassert
@@ -689,16 +689,1346 @@
 single%22)
+%0A        %0Aclass HistoryTest(unittest.TestCase):%0A    def test_reload_unicode(self):%0A        ip = ipapi.get()%0A        with TemporaryDirectory() as tmpdir:%0A            histfile = os.path.realpath(os.path.join(tmpdir, 'history.json'))%0A            # Ensure that we restore the history management that we mess with in%0A            # this test doesn't affect the IPython instance used by the test suite%0A            # beyond this test.%0A            hist_manager_ori = ip.history_manager%0A            try:%0A                ip.history_manager = HistoryManager(ip)%0A                ip.history_manager.hist_file = histfile%0A                print 'test',histfile%0A                hist = %5Bu%22t = '%C5%BE%C4%87%C4%8D%C5%A1%C4%91'%22%5D%0A                # test save and load%0A                ip.history_manager.input_hist_raw%5B:%5D = %5B%5D%0A                for h in hist:%0A                    ip.history_manager.input_hist_raw.append(h)%0A                ip.save_history()%0A                ip.history_manager.input_hist_raw%5B:%5D = %5B%5D%0A                ip.reload_history()%0A                self.assert_equal(len(ip.history_manager.input_hist_raw), len(hist))%0A                for i,h in enumerate(hist):%0A                    nt.assert_equal(hist%5Bi%5D, ip.history_manager.input_hist_raw%5Bi%5D)%0A            finally:%0A                # Restore history manager%0A                ip.history_manager = hist_manager_ori
 %0A%0Aif __n

Add test for reloading history including unicode (currently fails).