Skip to content

Commit

Permalink
Merge pull request #63 from kondratyev-nv/feature/fix_debug_arguments
Browse files Browse the repository at this point in the history
Pass pytest arguments for debug
  • Loading branch information
Nikolay Kondratyev authored Feb 6, 2019
2 parents bdd45a3 + 80cfaec commit 7eacfab
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pytest/pytestTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ import sys
import json
import py
from _pytest.compat import getfslineno
def get_line_number(item):
location = getattr(item, 'location', None)
if location is not None:
return location[1]
obj = getattr(item, 'obj', None)
if obj is not None:
return getfslineno(obj)[1]
try:
from _pytest.compat import getfslineno
return getfslineno(obj)[1]
except:
pass
return None
Expand Down Expand Up @@ -72,7 +73,7 @@ pytest.main(sys.argv[1:], plugins=[PythonTestExplorerDiscoveryOutputPlugin()])`;
return {
module: 'pytest',
cwd: config.getCwd(),
args: test !== this.adapterId ? [test] : [],
args: this.getRunArguments(test, config.getPytestConfiguration().pytestArguments),
envFile: config.envFile(),
};
}
Expand Down Expand Up @@ -112,11 +113,13 @@ pytest.main(sys.argv[1:], plugins=[PythonTestExplorerDiscoveryOutputPlugin()])`;

const additionalEnvironment = await EnvironmentVariablesLoader.load(config.envFile(), this.logger);
const { file, cleanupCallback } = await this.createTemporaryFile();
const runArguments = [`--junitxml=${file}`].concat(
this.getRunArguments(test, config.getPytestConfiguration().pytestArguments));
const testExecution = runScript({
pythonPath: config.pythonPath(),
script: PytestTestRunner.PYTEST_WRAPPER_SCRIPT,
cwd: config.getCwd(),
args: this.getRunArguments(test, file, config.getPytestConfiguration().pytestArguments),
args: runArguments,
environment: additionalEnvironment,
});
this.testExecutions.set(test, testExecution);
Expand All @@ -134,7 +137,7 @@ pytest.main(sys.argv[1:], plugins=[PythonTestExplorerDiscoveryOutputPlugin()])`;
return ['--collect-only'].concat(argumentsToPass);
}

private getRunArguments(test: string, outFile: string, rawPytestArguments: string[]): string[] {
private getRunArguments(test: string, rawPytestArguments: string[]): string[] {
const argumentParser = this.configureCommonArgumentParser();
argumentParser.addArgument(
['--setuponly', '--setup-only'],
Expand All @@ -152,7 +155,7 @@ pytest.main(sys.argv[1:], plugins=[PythonTestExplorerDiscoveryOutputPlugin()])`;
['--trace'],
{ dest: 'trace', action: 'storeTrue' });
const [, argumentsToPass] = argumentParser.parseKnownArgs(rawPytestArguments);
return [`--junitxml=${outFile}`].concat(argumentsToPass).concat(test !== this.adapterId ? [test] : []);
return argumentsToPass.concat(test !== this.adapterId ? [test] : []);
}

private configureCommonArgumentParser() {
Expand Down

0 comments on commit 7eacfab

Please sign in to comment.