fix(tests): sort setup.py dependencies by lineNumber (#3141)

Closes #3131, Closes #3136
This commit is contained in:
Ben 2019-01-30 21:32:38 +01:00 committed by Rhys Arkins
parent ca31580cb0
commit 59b1b747d7
2 changed files with 54 additions and 49 deletions

View file

@ -103,7 +103,12 @@ async function extractPackageFile(content, packageFile, config) {
}; };
return dep; return dep;
}) })
.filter(Boolean); .filter(Boolean)
.sort((a, b) =>
a.lineNumber === b.lineNumber
? (a.depName > b.depName) - (a.depName < b.depName)
: a.lineNumber - b.lineNumber
);
if (!deps.length) { if (!deps.length) {
return null; return null;
} }

View file

@ -3,6 +3,54 @@
exports[`lib/manager/pip_setup/extract extractPackageFile() returns found deps 1`] = ` exports[`lib/manager/pip_setup/extract extractPackageFile() returns found deps 1`] = `
Object { Object {
"deps": Array [ "deps": Array [
Object {
"currentValue": ">=3.1.13.0,<5.0",
"depName": "celery",
"lineNumber": 36,
"purl": "pkg:pypi/celery",
},
Object {
"currentValue": ">=1.7",
"depName": "logging_tree",
"lineNumber": 39,
"purl": "pkg:pypi/logging_tree",
},
Object {
"currentValue": ">=2.2",
"depName": "pygments",
"lineNumber": 40,
"purl": "pkg:pypi/pygments",
},
Object {
"currentValue": ">=5.0",
"depName": "psutil",
"lineNumber": 41,
"purl": "pkg:pypi/psutil",
},
Object {
"currentValue": ">=3.0",
"depName": "objgraph",
"lineNumber": 42,
"purl": "pkg:pypi/objgraph",
},
Object {
"currentValue": ">=1.10,<2.0",
"depName": "django",
"lineNumber": 45,
"purl": "pkg:pypi/django",
},
Object {
"currentValue": ">=0.11,<2.0",
"depName": "flask",
"lineNumber": 48,
"purl": "pkg:pypi/flask",
},
Object {
"currentValue": ">=1.4,<2.0",
"depName": "blinker",
"lineNumber": 49,
"purl": "pkg:pypi/blinker",
},
Object { Object {
"currentValue": ">=19.7.0,<20.0", "currentValue": ">=19.7.0,<20.0",
"depName": "gunicorn", "depName": "gunicorn",
@ -46,54 +94,6 @@ Object {
"lineNumber": 67, "lineNumber": 67,
"purl": "pkg:pypi/ipaddress", "purl": "pkg:pypi/ipaddress",
}, },
Object {
"currentValue": ">=3.1.13.0,<5.0",
"depName": "celery",
"lineNumber": 36,
"purl": "pkg:pypi/celery",
},
Object {
"currentValue": ">=0.11,<2.0",
"depName": "flask",
"lineNumber": 48,
"purl": "pkg:pypi/flask",
},
Object {
"currentValue": ">=1.4,<2.0",
"depName": "blinker",
"lineNumber": 49,
"purl": "pkg:pypi/blinker",
},
Object {
"currentValue": ">=1.7",
"depName": "logging_tree",
"lineNumber": 39,
"purl": "pkg:pypi/logging_tree",
},
Object {
"currentValue": ">=2.2",
"depName": "pygments",
"lineNumber": 40,
"purl": "pkg:pypi/pygments",
},
Object {
"currentValue": ">=5.0",
"depName": "psutil",
"lineNumber": 41,
"purl": "pkg:pypi/psutil",
},
Object {
"currentValue": ">=3.0",
"depName": "objgraph",
"lineNumber": 42,
"purl": "pkg:pypi/objgraph",
},
Object {
"currentValue": ">=1.10,<2.0",
"depName": "django",
"lineNumber": 45,
"purl": "pkg:pypi/django",
},
], ],
} }
`; `;