Skip to content

Commit f5bf0ca

Browse files
committed
#7 adding unit test for running modules
1 parent f08cc8b commit f5bf0ca

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/test-python-shell.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,35 @@ describe('PythonShell', function () {
192192
}
193193

194194
});
195+
196+
it('should be able to run modules', function(done){
197+
PythonShell.defaultOptions = {};
198+
199+
PythonShell.run('-m', {
200+
args: ['timeit', '-n 1', `'x=5'`]
201+
}, function (err, results) {
202+
203+
PythonShell.defaultOptions = {
204+
// reset to match initial value
205+
scriptPath: pythonFolder
206+
};
207+
208+
if (err) return done(err);
209+
results.should.be.an.Array();
210+
results[0].should.be.an.String();
211+
results[0].slice(0,6).should.eql('1 loop');
212+
done();
213+
});
214+
})
215+
216+
after(()=>{
217+
// should be able to run modules test should theoretically reset this
218+
// but we have this to in case something goes horribly wrong with the test
219+
PythonShell.defaultOptions = {
220+
// reset to match initial value
221+
scriptPath: pythonFolder
222+
};
223+
})
195224
});
196225

197226
describe('.send(message)', function () {

0 commit comments

Comments
 (0)