| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 85fdeca commit dccda47
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,7 @@ | |||
| 1 | 1 | var should = require('should'); | |
| 2 | 2 | var PythonShell = require('..'); | |
| 3 | + var path = require('path') | ||
| 4 | + const newline = require('os').EOL | ||
| 3 | 5 | ||
| 4 | 6 | describe('PythonShell', function () { | |
| 5 | 7 | ||
@@ -10,7 +12,7 @@ describe('PythonShell', function () { | |||
| 10 | 12 | describe('#ctor(script, options)', function () { | |
| 11 | 13 | it('should spawn a Python process', function (done) { | |
| 12 | 14 | var pyshell = new PythonShell('exit-code.py'); | |
| 13 | - pyshell.command.should.eql(['test/python/exit-code.py']); | ||
| 15 | + pyshell.command.should.eql(['test' + path.sep + 'python' + path.sep + 'exit-code.py']); | ||
| 14 | 16 | pyshell.terminated.should.be.false; | |
| 15 | 17 | pyshell.end(function (err) { | |
| 16 | 18 | if (err) return done(err); | |
@@ -22,14 +24,14 @@ describe('PythonShell', function () { | |||
| 22 | 24 | var pyshell = new PythonShell('exit-code.py', { | |
| 23 | 25 | pythonOptions: '-u' | |
| 24 | 26 | }); | |
| 25 | - pyshell.command.should.eql(['-u', 'test/python/exit-code.py']); | ||
| 27 | + pyshell.command.should.eql(['-u', 'test' + path.sep + 'python' + path.sep + 'exit-code.py']); | ||
| 26 | 28 | pyshell.end(done); | |
| 27 | 29 | }); | |
| 28 | 30 | it('should spawn a Python process with script arguments', function (done) { | |
| 29 | 31 | var pyshell = new PythonShell('echo_args.py', { | |
| 30 | 32 | args: ['hello', 'world'] | |
| 31 | 33 | }); | |
| 32 | - pyshell.command.should.eql(['test/python/echo_args.py', 'hello', 'world']); | ||
| 34 | + pyshell.command.should.eql(['test' + path.sep + 'python' + path.sep + 'echo_args.py', 'hello', 'world']); | ||
| 33 | 35 | pyshell.end(done); | |
| 34 | 36 | }); | |
| 35 | 37 | }); | |
@@ -119,7 +121,7 @@ describe('PythonShell', function () { | |||
| 119 | 121 | }); | |
| 120 | 122 | pyshell.send('hello').send('world').end(function (err) { | |
| 121 | 123 | if (err) return done(err); | |
| 122 | - output.should.be.exactly('hello\nworld\n'); | ||
| 124 | + output.should.be.exactly('hello'+newline+'world'+newline); | ||
| 123 | 125 | done(); | |
| 124 | 126 | }); | |
| 125 | 127 | }); | |
@@ -133,7 +135,7 @@ describe('PythonShell', function () { | |||
| 133 | 135 | }); | |
| 134 | 136 | pyshell.send({ a: 'b' }).send(null).send([1, 2, 3]).end(function (err) { | |
| 135 | 137 | if (err) return done(err); | |
| 136 | - output.should.be.exactly('{"a": "b"}\nnull\n[1, 2, 3]\n'); | ||
| 138 | + output.should.be.exactly('{"a": "b"}'+newline+'null'+newline+'[1, 2, 3]'+newline); | ||
| 137 | 139 | done(); | |
| 138 | 140 | }); | |
| 139 | 141 | }); | |
@@ -149,7 +151,7 @@ describe('PythonShell', function () { | |||
| 149 | 151 | }); | |
| 150 | 152 | pyshell.send('hello').send('world').end(function (err) { | |
| 151 | 153 | if (err) return done(err); | |
| 152 | - output.should.be.exactly('HELLO\nWORLD\n'); | ||
| 154 | + output.should.be.exactly('HELLO'+newline+'WORLD'+newline+''); | ||
| 153 | 155 | done(); | |
| 154 | 156 | }); | |
| 155 | 157 | }); | |
@@ -205,7 +207,7 @@ describe('PythonShell', function () { | |||
| 205 | 207 | pyshell.on('message', function (message) { | |
| 206 | 208 | message.should.be.an.Object; | |
| 207 | 209 | message.should.eql({ a: true }); | |
| 208 | - }).receive('{"a"').receive(':').receive('true}\n').end(done); | ||
| 210 | + }).receive('{"a"').receive(':').receive('true}'+newline+'').end(done); | ||
| 209 | 211 | }); | |
| 210 | 212 | it('should not be invoked when mode is "binary"', function (done) { | |
| 211 | 213 | var pyshell = new PythonShell('echo_args.py', { | |
@@ -281,8 +283,8 @@ describe('PythonShell', function () { | |||
| 281 | 283 | var pyshell = new PythonShell('error.py'); | |
| 282 | 284 | pyshell.on('error', function (err) { | |
| 283 | 285 | err.stack.should.containEql('----- Python Traceback -----'); | |
| 284 | - err.stack.should.containEql('File "test/python/error.py", line 6'); | ||
| 285 | - err.stack.should.containEql('File "test/python/error.py", line 4'); | ||
| 286 | + err.stack.should.containEql('File "test' + path.sep + 'python' + path.sep + 'error.py", line 4'); | ||
| 287 | + err.stack.should.containEql('File "test' + path.sep + 'python' + path.sep + 'error.py", line 6'); | ||
| 286 | 288 | done(); | |
| 287 | 289 | }); | |
| 288 | 290 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments