Skip to content

Commit

Permalink
Merge pull request #95 from kondratyev-nv/feature/fix_pytest_5_1_comp…
Browse files Browse the repository at this point in the history
…atibility

Fix pytest 5.1.0 compatibility on parsing junit xml
  • Loading branch information
Nikolay Kondratyev authored Aug 20, 2019
2 parents b3c4a13 + 6f62d5c commit 3143124
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/pytest/pytestJunitTestStatesParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ function parseTestResults(parserResult: any, cwd: string) {
if (!parserResult) {
return [];
}
const testSuiteResult: ITestSuiteResult = parserResult.testsuite;
if (!Array.isArray(testSuiteResult.testcase)) {
return [];
}
return testSuiteResult.testcase.map(testcase => mapToTestState(testcase, cwd)).filter(x => x);
const testSuiteResults: ITestSuiteResult[] = parserResult.testsuites ?
parserResult.testsuites.testsuite : // from pytest 5.1.0, see https://github.com/pytest-dev/pytest/issues/5477
[parserResult.testsuite]; // before pytest 5.1.0
return testSuiteResults.map(testSuiteResult => {
if (!Array.isArray(testSuiteResult.testcase)) {
return [];
}
return testSuiteResult.testcase.map(testcase => mapToTestState(testcase, cwd)).filter(x => x);
}).reduce((r, x) => r.concat(x), []);
}

function mapToTestState(testcase: ITestCaseResult, cwd: string) {
Expand Down

0 comments on commit 3143124

Please sign in to comment.