##// END OF EJS Templates
IPython.testing.decorators is imported as dec everywhere else, unify....
Thomas Spura -
Show More
@@ -1,50 +1,50 b''
1 1 # coding: utf-8
2 2 """Tests for IPython.core.application"""
3 3
4 4 import os
5 5 import tempfile
6 6
7 7 from IPython.core.application import BaseIPythonApplication
8 from IPython.testing import decorators as testdec
8 from IPython.testing import decorators as dec
9 9 from IPython.utils import py3compat
10 10
11 @testdec.onlyif_unicode_paths
11 @dec.onlyif_unicode_paths
12 12 def test_unicode_cwd():
13 13 """Check that IPython starts with non-ascii characters in the path."""
14 14 wd = tempfile.mkdtemp(suffix=u"€")
15 15
16 16 old_wd = os.getcwdu()
17 17 os.chdir(wd)
18 18 #raise Exception(repr(os.getcwdu()))
19 19 try:
20 20 app = BaseIPythonApplication()
21 21 # The lines below are copied from Application.initialize()
22 22 app.init_profile_dir()
23 23 app.init_config_files()
24 24 app.load_config_file(suppress_errors=False)
25 25 finally:
26 26 os.chdir(old_wd)
27 27
28 @testdec.onlyif_unicode_paths
28 @dec.onlyif_unicode_paths
29 29 def test_unicode_ipdir():
30 30 """Check that IPython starts with non-ascii characters in the IP dir."""
31 31 ipdir = tempfile.mkdtemp(suffix=u"€")
32 32
33 33 # Create the config file, so it tries to load it.
34 34 with open(os.path.join(ipdir, 'ipython_config.py'), "w") as f:
35 35 pass
36 36
37 37 old_ipdir1 = os.environ.pop("IPYTHONDIR", None)
38 38 old_ipdir2 = os.environ.pop("IPYTHON_DIR", None)
39 39 os.environ["IPYTHONDIR"] = py3compat.unicode_to_str(ipdir, "utf-8")
40 40 try:
41 41 app = BaseIPythonApplication()
42 42 # The lines below are copied from Application.initialize()
43 43 app.init_profile_dir()
44 44 app.init_config_files()
45 45 app.load_config_file(suppress_errors=False)
46 46 finally:
47 47 if old_ipdir1:
48 48 os.environ["IPYTHONDIR"] = old_ipdir1
49 49 if old_ipdir2:
50 50 os.environ["IPYTHONDIR"] = old_ipdir2
@@ -1,68 +1,68 b''
1 1 # encoding: utf-8
2 2 """
3 3 Test process execution and IO redirection.
4 4 """
5 5
6 6 __docformat__ = "restructuredtext en"
7 7
8 8 #-----------------------------------------------------------------------------
9 9 # Copyright (C) 2008-2011 The IPython Development Team
10 10 #
11 11 # Distributed under the terms of the BSD License. The full license is
12 12 # in the file COPYING, distributed as part of this software.
13 13 #-----------------------------------------------------------------------------
14 14
15 15 from cStringIO import StringIO
16 16 from time import sleep
17 17 import sys
18 18
19 19 from IPython.frontend.process import PipedProcess
20 from IPython.testing import decorators as testdec
20 from IPython.testing import decorators as dec
21 21
22 22
23 23 def test_capture_out():
24 24 """ A simple test to see if we can execute a process and get the output.
25 25 """
26 26 s = StringIO()
27 27 p = PipedProcess('echo 1', out_callback=s.write, )
28 28 p.start()
29 29 p.join()
30 30 result = s.getvalue().rstrip()
31 31 assert result == '1'
32 32
33 33
34 34 def test_io():
35 35 """ Checks that we can send characters on stdin to the process.
36 36 """
37 37 s = StringIO()
38 38 p = PipedProcess(sys.executable + ' -c "a = raw_input(); print a"',
39 39 out_callback=s.write, )
40 40 p.start()
41 41 test_string = '12345\n'
42 42 while not hasattr(p, 'process'):
43 43 sleep(0.1)
44 44 p.process.stdin.write(test_string)
45 45 p.join()
46 46 result = s.getvalue()
47 47 assert result == test_string
48 48
49 49
50 @testdec.skip_win32
50 @dec.skip_win32
51 51 def test_kill():
52 52 """ Check that we can kill a process, and its subprocess.
53 53 """
54 54 s = StringIO()
55 55 p = PipedProcess(sys.executable + ' -c "a = raw_input();"',
56 56 out_callback=s.write, )
57 57 p.start()
58 58 while not hasattr(p, 'process'):
59 59 sleep(0.1)
60 60 p.process.kill()
61 61 assert p.process.poll() is not None
62 62
63 63
64 64 if __name__ == '__main__':
65 65 test_capture_out()
66 66 test_io()
67 67 test_kill()
68 68
General Comments 0
You need to be logged in to leave comments. Login now