Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix no test id provided for pytest run #22569

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

Choose a reason for hiding this comment

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

Are these print statements supposed to stay here?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch thank you!

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")
Loading