| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 074e55c commit 4ba8b5e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,7 +113,7 @@ export class PythonShell extends EventEmitter{ | |||
| 113 | 113 | let pythonOptions = toArray(options.pythonOptions); | |
| 114 | 114 | let scriptArgs = toArray(options.args); | |
| 115 | 115 | ||
| 116 | - this.scriptPath = join(options.scriptPath || './', scriptPath); | ||
| 116 | + this.scriptPath = join(options.scriptPath || '', scriptPath); | ||
| 117 | 117 | this.command = pythonOptions.concat(this.scriptPath, scriptArgs); | |
| 118 | 118 | this.mode = options.mode || 'text'; | |
| 119 | 119 | this.formatter = resolve('format', options.formatter || this.mode); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,15 @@ | |||
| 1 | 1 | import * as should from 'should'; | |
| 2 | 2 | import {PythonShell} from '..' | |
| 3 | - import {sep} from 'path' | ||
| 3 | + import {sep, join} from 'path' | ||
| 4 | 4 | import {EOL as newline} from 'os' | |
| 5 | + import { chdir, cwd } from 'process'; | ||
| 5 | 6 | ||
| 6 | 7 | describe('PythonShell', function () { | |
| 7 | 8 | ||
| 9 | + const pythonFolder = 'test/python' | ||
| 10 | + | ||
| 8 | 11 | PythonShell.defaultOptions = { | |
| 9 | - scriptPath: './test/python' | ||
| 12 | + scriptPath: pythonFolder | ||
| 10 | 13 | }; | |
| 11 | 14 | ||
| 12 | 15 | describe('#ctor(script, options)', function () { | |
@@ -20,6 +23,27 @@ describe('PythonShell', function () { | |||
| 20 | 23 | done(); | |
| 21 | 24 | }); | |
| 22 | 25 | }); | |
| 26 | + it('should spawn a Python process even if scriptPath option is not specified', function (done) { | ||
| 27 | + let originalDirectory = cwd() | ||
| 28 | + PythonShell.defaultOptions = {}; | ||
| 29 | + chdir(join(__dirname, "python")); | ||
| 30 | + | ||
| 31 | + let pyshell = new PythonShell('exit-code.py'); | ||
| 32 | + pyshell.command.should.eql(['exit-code.py']); | ||
| 33 | + pyshell.terminated.should.be.false; | ||
| 34 | + pyshell.end(function (err) { | ||
| 35 | + if (err) return done(err); | ||
| 36 | + pyshell.terminated.should.be.true; | ||
| 37 | + done(); | ||
| 38 | + }); | ||
| 39 | + | ||
| 40 | + //reset values to intial status | ||
| 41 | + PythonShell.defaultOptions = { | ||
| 42 | + scriptPath: pythonFolder | ||
| 43 | + }; | ||
| 44 | + chdir(originalDirectory) | ||
| 45 | + }); | ||
| 46 | + // executing python-shell with a absolute path is tested in runString suite | ||
| 23 | 47 | it('should spawn a Python process with options', function (done) { | |
| 24 | 48 | let pyshell = new PythonShell('exit-code.py', { | |
| 25 | 49 | pythonOptions: ['-u'] | |
@@ -69,7 +93,7 @@ describe('PythonShell', function () { | |||
| 69 | 93 | after(()=>{ | |
| 70 | 94 | PythonShell.defaultOptions = { | |
| 71 | 95 | // reset to match initial value | |
| 72 | - scriptPath: './test/python' | ||
| 96 | + scriptPath: pythonFolder | ||
| 73 | 97 | }; | |
| 74 | 98 | }) | |
| 75 | 99 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments