Skip to content

Commit

Permalink
fix no test id provided for pytest run
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Nov 29, 2023
1 parent db6e15e commit cb64bc4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pythonFiles/vscode_pytest/run_pytest_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

if __name__ == "__main__":
# Add the root directory to the path so that we can import the plugin.
print("HERE, in the run_pytest_script.py")
directory_path = pathlib.Path(__file__).parent.parent
sys.path.append(os.fspath(directory_path))
sys.path.insert(0, os.getcwd())
Expand Down Expand Up @@ -53,7 +54,7 @@
)
# Clear the buffer as complete JSON object is received
buffer = b""
print("Received JSON data in run script")
print("Received JSON data in run script, 2")
break
except json.JSONDecodeError:
# JSON decoding error, the complete JSON object is not yet received
Expand All @@ -64,6 +65,14 @@
try:
if test_ids_from_buffer:
arg_array = ["-p", "vscode_pytest"] + args + test_ids_from_buffer
print("Running pytest with args: " + str(arg_array))
pytest.main(arg_array)
else:
print(
"Error: No test ids received from stdin, could be an error or a run request without ids provided.",
)
print("Running pytest with no test ids as args. Args being used: ", args)
arg_array = ["-p", "vscode_pytest"] + args
pytest.main(arg_array)
except json.JSONDecodeError:
print("Error: Could not parse test ids from stdin")

0 comments on commit cb64bc4

Please sign in to comment.