Skip to content

Conversation

@d3r3kk
Copy link

@d3r3kk d3r3kk commented Aug 30, 2018

Fixes #2347

  • Add the 'Package' information to the Parser

  • Correct how we discover mixed package/non-package tests

  • Add unit tests for < 3.7.0 parsing

  • Add unit tests for >= 3.7.0 parsing

  • Title summarizes what is changing

  • Has a news entry file (remember to thank yourself!)

  • Has unit tests & system/integration tests

  • Any new/changed dependencies in package.json are pinned (e.g. "1.2.3", not "^1.2.3" for the specified version)

  • package-lock.json has been regenerated by running npm install (if dependencies have changed)


WIP - Additional tasks to complete

  • Add further test scenarios by collecting stdout from pytest in Windows
  • Alter unit tests to consume JSON data collected (make unit tests data-driven)

const trimmedLine: string = line.trim();

if (trimmedLine.startsWith('<Package \'')) {
// process the previous lines
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Process the previous lines."

private parsePyTestModuleCollectionResult(rootDirectory: string, lines: string[], testFiles: TestFile[], parentNodes: { indent: number; item: TestFile | TestSuite }[]) {

/**
* Extract the 'package' name from a given PyTest (>= 3.7) output line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a period.

runner.verifyAll();
testParser.verifyAll();
});
// build tests for the test data that is relevant for this platform.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Build"

});
// build tests for the test data that is relevant for this platform.
pytestScenarioData.forEach((testScenario) => {
const testPlatformType: PytestDataPlatformType =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be re-calculated for each test scenario?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, fixed.


// tslint:disable-next-line:no-invalid-this
if (testPlatformType === testScenario.platform) {
const testDescription: string = 'PyTest '.concat('[', testScenario.pytest_version_spec, '] ', testScenario.description);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use string interpolation?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, changed.

@d3r3kk d3r3kk force-pushed the 2347_pytest_codelens branch from 3e7d698 to 8a6e6b7 Compare August 31, 2018 22:07
d3r3kk and others added 10 commits August 31, 2018 15:08
Fix microsoft#2347

- Add the 'Package' information to the Parser
- Correct how we discover mixed package/non-package tests
- Add unit tests for < 3.7.0 parsing
- Add unit tests for >= 3.7.0 parsing
- add json test data for running through various scenarios (WIP)
- Better for coping with many scenarios
- Update tests to pull scenario data from json file
- Linux/macOS scenarios are covered
- TODO: Windows
- Discovery and parsing are related but belong in separate files
@d3r3kk d3r3kk force-pushed the 2347_pytest_codelens branch from 8a6e6b7 to 7dbf4db Compare August 31, 2018 22:08
d3r3kk added 2 commits August 31, 2018 18:11
- remove some unnecessary operations from for loop.
- correct string construction to use interpolation.
@d3r3kk d3r3kk changed the title [WIP] Update parser for pytest to handle changes in pytest >= 3.7 (while still supporting pytest < 3.7) Update parser for pytest to handle changes in pytest >= 3.7 (while still supporting pytest < 3.7) Sep 1, 2018
@d3r3kk d3r3kk merged commit dfd3f61 into microsoft:master Sep 1, 2018
@d3r3kk d3r3kk deleted the 2347_pytest_codelens branch September 1, 2018 01:40
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code lens not present overtop test code when using PyTest >= 3.7

2 participants