TLDR:
- do not run all tests when test execution fails
- also, do not run tests at all when you cannot collect the IDs
I am currently debugging a problem in my tests, most likely related to coveragepy/coveragepy#1392. I am trying the omit workaround, but currently, I am getting vscode-pytest errors such as:
test_bug.py . [100%]Error[vscode-pytest]: unable to read testIds from temp fileNo source for code: 'C:\Git\Bug\shibokensupport\signature\lib\tool.py'.
When this happens, VS Code re-starts all tests, which is not what I want at all.
Compare this snippet:
|
try: |
|
# Read the test ids from the file, delete file, and run pytest. |
|
ids_path = pathlib.Path(run_test_ids_pipe) |
|
ids = ids_path.read_text(encoding="utf-8").splitlines() |
|
try: |
|
ids_path.unlink() |
|
except Exception as e: |
|
print("Error[vscode-pytest]: unable to delete temp file" + str(e)) |
|
arg_array = ["-p", "vscode_pytest", *args, *ids] |
|
print("Running pytest with args: " + str(arg_array)) |
|
pytest.main(arg_array) |
|
except Exception as e: |
|
print("Error[vscode-pytest]: unable to read testIds from temp file" + str(e)) |
|
run_pytest(args) |
IMHO, this should rather be something like (untested!) - note the return in the first block and the different arg_array in the last block:
try:
# Read the test ids from the file, delete file, and run pytest.
ids_path = pathlib.Path(run_test_ids_pipe)
ids = ids_path.read_text(encoding="utf-8").splitlines()
except Exception as e:
print("Error[vscode-pytest]: unable to read testIds from temp file: " + str(e))
return
finally:
try:
ids_path.unlink()
except Exception as e:
print("Error[vscode-pytest]: unable to delete temp file: " + str(e))
try:
arg_array = ["-p", "vscode_pytest", *args, *ids]
print("Running pytest with args: " + str(arg_array))
pytest.main(arg_array)
except Exception as e:
print("Error[vscode-pytest]: unable to run tests: " + str(e))
arg_array = [*args, *ids]
print("Running pytest with args: " + str(arg_array))
run_pytest(arg_array)
TLDR:
I am currently debugging a problem in my tests, most likely related to coveragepy/coveragepy#1392. I am trying the
omitworkaround, but currently, I am gettingvscode-pytesterrors such as:When this happens, VS Code re-starts all tests, which is not what I want at all.
Compare this snippet:
vscode-python/python_files/vscode_pytest/run_pytest_script.py
Lines 54 to 67 in e8dd8c0
IMHO, this should rather be something like (untested!) - note the
returnin the first block and the differentarg_arrayin the last block: