Skip to content

Commit cf22a7c

Browse files
committed
Add trim and add test
1 parent f7048bd commit cf22a7c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/poetry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function pyprojectTomlToRequirements() {
3636
const editableFlag = new RegExp(/^-e /gm);
3737
const sourceRequirements = path.join(this.servicePath, 'requirements.txt');
3838
const requirementsContents =
39-
res.stdout.toString() || // As of poetry 1.0.0b1, requirements.txt is printed to standard output when the -o option is not specified.
39+
res.stdout.toString().trim() || // As of poetry 1.0.0b1, requirements.txt is printed to standard output when the -o option is not specified.
4040
fse.readFileSync(sourceRequirements, {
4141
encoding: 'utf-8'
4242
});

test.js

+15
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const sls = mkCommand('sls');
5151
const git = mkCommand('git');
5252
const npm = mkCommand('npm');
5353
const perl = mkCommand('perl');
54+
const poetry = mkCommand('poetry');
5455

5556
const setup = () => {
5657
removeSync(getUserCachePath());
@@ -1874,3 +1875,17 @@ test(
18741875
},
18751876
{ skip: !canUseDocker() }
18761877
);
1878+
1879+
// From this point on, the version of the poetry is 1.0.0a0
1880+
test('poetry1.0.0a0 py3.6 can package flask with default options', t => {
1881+
process.chdir('tests/poetry');
1882+
const path = npm(['pack', '../..']);
1883+
npm(['i', path]);
1884+
poetry(['self', 'update', '--preview', '1.0.0a0']);
1885+
sls(['package']);
1886+
const zipfiles = listZipFiles('.serverless/sls-py-req-test.zip');
1887+
t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged');
1888+
t.true(zipfiles.includes(`bottle.py`), 'bottle is packaged');
1889+
t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged');
1890+
t.end();
1891+
});

0 commit comments

Comments
 (0)