Show More
@@ -15,6 +15,7 b' Tests for platutils.py' | |||||
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 |
|
16 | |||
17 | import sys |
|
17 | import sys | |
|
18 | import os | |||
18 | from unittest import TestCase |
|
19 | from unittest import TestCase | |
19 |
|
20 | |||
20 | import nose.tools as nt |
|
21 | import nose.tools as nt | |
@@ -24,13 +25,15 b' from IPython.utils.process import (find_cmd, FindCmdError, arg_split,' | |||||
24 | from IPython.testing import decorators as dec |
|
25 | from IPython.testing import decorators as dec | |
25 | from IPython.testing import tools as tt |
|
26 | from IPython.testing import tools as tt | |
26 |
|
27 | |||
|
28 | python = os.path.basename(sys.executable) | |||
|
29 | ||||
27 | #----------------------------------------------------------------------------- |
|
30 | #----------------------------------------------------------------------------- | |
28 | # Tests |
|
31 | # Tests | |
29 | #----------------------------------------------------------------------------- |
|
32 | #----------------------------------------------------------------------------- | |
30 |
|
33 | |||
31 | def test_find_cmd_python(): |
|
34 | def test_find_cmd_python(): | |
32 | """Make sure we find sys.exectable for python.""" |
|
35 | """Make sure we find sys.exectable for python.""" | |
33 |
nt.assert_equal(find_cmd( |
|
36 | nt.assert_equal(find_cmd(python), sys.executable) | |
34 |
|
37 | |||
35 |
|
38 | |||
36 | @dec.skip_win32 |
|
39 | @dec.skip_win32 | |
@@ -102,15 +105,15 b' class SubProcessTestCase(TestCase, tt.TempFileMixin):' | |||||
102 | self.mktmp('\n'.join(lines)) |
|
105 | self.mktmp('\n'.join(lines)) | |
103 |
|
106 | |||
104 | def test_system(self): |
|
107 | def test_system(self): | |
105 |
status = system(' |
|
108 | status = system('%s "%s"' % (python, self.fname)) | |
106 | self.assertEqual(status, 0) |
|
109 | self.assertEqual(status, 0) | |
107 |
|
110 | |||
108 | def test_system_quotes(self): |
|
111 | def test_system_quotes(self): | |
109 |
status = system(' |
|
112 | status = system('%s -c "import sys"' % python) | |
110 | self.assertEqual(status, 0) |
|
113 | self.assertEqual(status, 0) | |
111 |
|
114 | |||
112 | def test_getoutput(self): |
|
115 | def test_getoutput(self): | |
113 |
out = getoutput(' |
|
116 | out = getoutput('%s "%s"' % (python, self.fname)) | |
114 | # we can't rely on the order the line buffered streams are flushed |
|
117 | # we can't rely on the order the line buffered streams are flushed | |
115 | try: |
|
118 | try: | |
116 | self.assertEqual(out, 'on stderron stdout') |
|
119 | self.assertEqual(out, 'on stderron stdout') | |
@@ -118,18 +121,18 b' class SubProcessTestCase(TestCase, tt.TempFileMixin):' | |||||
118 | self.assertEqual(out, 'on stdouton stderr') |
|
121 | self.assertEqual(out, 'on stdouton stderr') | |
119 |
|
122 | |||
120 | def test_getoutput_quoted(self): |
|
123 | def test_getoutput_quoted(self): | |
121 |
out = getoutput(' |
|
124 | out = getoutput('%s -c "print (1)"' % python) | |
122 | self.assertEqual(out.strip(), '1') |
|
125 | self.assertEqual(out.strip(), '1') | |
123 |
|
126 | |||
124 | #Invalid quoting on windows |
|
127 | #Invalid quoting on windows | |
125 | @dec.skip_win32 |
|
128 | @dec.skip_win32 | |
126 | def test_getoutput_quoted2(self): |
|
129 | def test_getoutput_quoted2(self): | |
127 |
out = getoutput(" |
|
130 | out = getoutput("%s -c 'print (1)'" % python) | |
128 | self.assertEqual(out.strip(), '1') |
|
131 | self.assertEqual(out.strip(), '1') | |
129 |
out = getoutput(" |
|
132 | out = getoutput("%s -c 'print (\"1\")'" % python) | |
130 | self.assertEqual(out.strip(), '1') |
|
133 | self.assertEqual(out.strip(), '1') | |
131 |
|
134 | |||
132 | def test_getoutput_error(self): |
|
135 | def test_getoutput_error(self): | |
133 |
out, err = getoutputerror(' |
|
136 | out, err = getoutputerror('%s "%s"' % (python, self.fname)) | |
134 | self.assertEqual(out, 'on stdout') |
|
137 | self.assertEqual(out, 'on stdout') | |
135 | self.assertEqual(err, 'on stderr') |
|
138 | self.assertEqual(err, 'on stderr') |
General Comments 0
You need to be logged in to leave comments.
Login now