forked from 73rhodes/node-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.test.js
More file actions
36 lines (31 loc) · 915 Bytes
/
python.test.js
File metadata and controls
36 lines (31 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var assert = require('assert');
var python = require('../lib/python').shell;
var testCounter = 0;
var runTests = function() {
// Run a couple commands in series
python('print("Hello World!")', function(err, data) {
assert.equal('Hello World!\n', data);
console.log('test 1 ok!');
completeTest();
python('print("Goodbye, Cruel World!")', function (err, data) {
assert.equal('Goodbye, Cruel World!\n', data);
console.log('test 2 ok!');
python('quit()');
completeTest();
});
});
// Run one in parallel with the first two
python('print("Asynch")', function (err, data) {
assert.equal('Asynch\n', data);
console.log('test 3 ok!');
completeTest();
});
};
function completeTest() {
testCounter++;
if (testCounter >= 3) {
console.log("All tests completed ok.");
process.exit(0);
}
}
runTests();