Skip to content

Commit 86579f2

Browse files
committed
python versions are a pain in appveyor / on windows
1 parent 88ccea8 commit 86579f2

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

test.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,16 @@ const test = (desc, func) =>
7272
}
7373
});
7474

75-
test('py3.6 can package flask with default options', t => {
75+
const getPythonBin = (version = 3) => {
76+
if (![2, 3].includes(version))
77+
throw new Error('version must be 2 or 3')
78+
if (process.platform === 'win32')
79+
return `c:/python${version === 2 ? '27' : '36'}-x64/python.exe`;
80+
else
81+
return version === 2 ? 'python2.7' : 'python3.6';
82+
};
83+
84+
test('default pythonBin can package flask with default options', t => {
7685
process.chdir('tests/base');
7786
const path = npm(['pack', '../..']);
7887
npm(['i', path]);
@@ -83,11 +92,22 @@ test('py3.6 can package flask with default options', t => {
8392
t.end();
8493
});
8594

95+
test('py3.6 can package flask with default options', t => {
96+
process.chdir('tests/base');
97+
const path = npm(['pack', '../..']);
98+
npm(['i', path]);
99+
sls([`--pythonBin=${getPythonBin(3)}`, 'package']);
100+
unzip(['.serverless/sls-py-req-test.zip', '-d', 'puck']);
101+
const files = readdirSync('puck');
102+
t.true(files.includes('flask'), 'flask is packaged');
103+
t.end();
104+
});
105+
86106
test('py3.6 can package flask with zip option', t => {
87107
process.chdir('tests/base');
88108
const path = npm(['pack', '../..']);
89109
npm(['i', path]);
90-
sls(['--zip=true', 'package']);
110+
sls([`--pythonBin=${getPythonBin(3)}`, '--zip=true', 'package']);
91111
unzip(['.serverless/sls-py-req-test.zip', '-d', 'puck']);
92112
const files = readdirSync('puck');
93113
t.true(
@@ -103,7 +123,7 @@ test('py3.6 can package flask with slim option', t => {
103123
process.chdir('tests/base');
104124
const path = npm(['pack', '../..']);
105125
npm(['i', path]);
106-
sls(['--slim=true', 'package']);
126+
sls([`--pythonBin=${getPythonBin(3)}`, '--slim=true', 'package']);
107127
unzip(['.serverless/sls-py-req-test.zip', '-d', 'puck']);
108128
const files = readdirSync('puck');
109129
t.true(files.includes('flask'), 'flask is packaged');

0 commit comments

Comments
 (0)