Skip to content

Commit a17bc93

Browse files
authored
Support expectedFailure when running unittest tests using pytest (microsoft#17623)
* Support `expectedFailure` when running `unittest` tests using `pytest` * Move to enhancements.
1 parent 31e62d5 commit a17bc93

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

news/1 Enhancements/8427.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support `expectedFailure` when running `unittest` tests using `pytest`.

src/client/testing/testController/common/resultsHelper.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,18 @@ export async function updateResultFromJunitXml(
128128
runInstance.failed(node, message);
129129
runInstance.appendOutput(fixLogLines(text));
130130
} else if (result.skipped) {
131-
skipped += 1;
132131
const skip = result.skipped[0];
133-
const text = `${rawTestCaseNode.rawId} Skipped: [${skip.$.type}]${skip.$.message}\r\n`;
134-
135-
runInstance.skipped(node);
132+
let text = '';
133+
if (skip.$.type === 'pytest.xfail') {
134+
passed += 1;
135+
// pytest.xfail ==> expected failure via @unittest.expectedFailure
136+
text = `${rawTestCaseNode.rawId} Passed: [${skip.$.type}]${skip.$.message}\r\n`;
137+
runInstance.passed(node);
138+
} else {
139+
skipped += 1;
140+
text = `${rawTestCaseNode.rawId} Skipped: [${skip.$.type}]${skip.$.message}\r\n`;
141+
runInstance.skipped(node);
142+
}
136143
runInstance.appendOutput(fixLogLines(text));
137144
} else {
138145
passed += 1;

0 commit comments

Comments
 (0)