##// END OF EJS Templates
py3compat fixes for %%script and tests
MinRK -
Show More
@@ -185,7 +185,8 b' class ScriptMagics(Magics, Configurable):'
185 args, cmd = self.shebang.parser.parse_known_args(argv)
185 args, cmd = self.shebang.parser.parse_known_args(argv)
186
186
187 p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)
187 p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)
188
188
189 cell = cell.encode('utf8', 'replace')
189 if args.bg:
190 if args.bg:
190 if args.out:
191 if args.out:
191 self.shell.user_ns[args.out] = p.stdout
192 self.shell.user_ns[args.out] = p.stdout
@@ -638,20 +638,20 b' def test_script_out_err():'
638 def test_script_bg_out():
638 def test_script_bg_out():
639 ip = get_ipython()
639 ip = get_ipython()
640 ip.run_cell_magic("script", "--bg --out output sh", "echo 'hi'")
640 ip.run_cell_magic("script", "--bg --out output sh", "echo 'hi'")
641 nt.assert_equals(ip.user_ns['output'].read(), 'hi\n')
641 nt.assert_equals(ip.user_ns['output'].read(), b'hi\n')
642
642
643 @dec.skip_win32
643 @dec.skip_win32
644 def test_script_bg_err():
644 def test_script_bg_err():
645 ip = get_ipython()
645 ip = get_ipython()
646 ip.run_cell_magic("script", "--bg --err error sh", "echo 'hello' >&2")
646 ip.run_cell_magic("script", "--bg --err error sh", "echo 'hello' >&2")
647 nt.assert_equals(ip.user_ns['error'].read(), 'hello\n')
647 nt.assert_equals(ip.user_ns['error'].read(), b'hello\n')
648
648
649 @dec.skip_win32
649 @dec.skip_win32
650 def test_script_bg_out_err():
650 def test_script_bg_out_err():
651 ip = get_ipython()
651 ip = get_ipython()
652 ip.run_cell_magic("script", "--bg --out output --err error sh", "echo 'hi'\necho 'hello' >&2")
652 ip.run_cell_magic("script", "--bg --out output --err error sh", "echo 'hi'\necho 'hello' >&2")
653 nt.assert_equals(ip.user_ns['output'].read(), 'hi\n')
653 nt.assert_equals(ip.user_ns['output'].read(), b'hi\n')
654 nt.assert_equals(ip.user_ns['error'].read(), 'hello\n')
654 nt.assert_equals(ip.user_ns['error'].read(), b'hello\n')
655
655
656 def test_script_defaults():
656 def test_script_defaults():
657 ip = get_ipython()
657 ip = get_ipython()
General Comments 0
You need to be logged in to leave comments. Login now