Skip to content

Commit 67367bb

Browse files
karthiknadigeleanorjboyd
authored andcommitted
Some tweaks
1 parent c77994b commit 67367bb

File tree

2 files changed

+15
-32
lines changed

2 files changed

+15
-32
lines changed

python_files/vscode_pytest/__init__.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@
2020

2121
import pytest
2222

23-
24-
# sys.path.append("/Users/eleanorboyd/vscode-python/.nox/install_python_libs/lib/python3.10")
25-
# sys.path.append("/Users/eleanorboyd/vscode-python-debugger")
26-
# sys.path.append("/Users/eleanorboyd/vscode-python-debugger/bundled")
27-
# sys.path.append("/Users/eleanorboyd/vscode-python-debugger/bundled/libs")
28-
29-
# import debugpy # noqa: E402
30-
31-
# debugpy.connect(5678)
32-
# debugpy.breakpoint() # noqa: E702
33-
3423
if TYPE_CHECKING:
3524
from pluggy import Result
3625

@@ -161,7 +150,7 @@ def pytest_exception_interact(node, call, report):
161150
collected_test = TestRunResultDict()
162151
collected_test[node_id] = item_result
163152
cwd = pathlib.Path.cwd()
164-
execution_post(
153+
send_execution_message(
165154
os.fsdecode(cwd),
166155
"success",
167156
collected_test if collected_test else None,
@@ -285,7 +274,7 @@ def pytest_report_teststatus(report, config): # noqa: ARG001
285274
)
286275
collected_test = TestRunResultDict()
287276
collected_test[absolute_node_id] = item_result
288-
execution_post(
277+
send_execution_message(
289278
os.fsdecode(cwd),
290279
"success",
291280
collected_test if collected_test else None,
@@ -319,7 +308,7 @@ def pytest_runtest_protocol(item, nextitem): # noqa: ARG001
319308
)
320309
collected_test = TestRunResultDict()
321310
collected_test[absolute_node_id] = item_result
322-
execution_post(
311+
send_execution_message(
323312
os.fsdecode(cwd),
324313
"success",
325314
collected_test if collected_test else None,
@@ -395,15 +384,15 @@ def pytest_sessionfinish(session, exitstatus):
395384
"children": [],
396385
"id_": "",
397386
}
398-
post_response(os.fsdecode(cwd), error_node)
387+
send_discovery_message(os.fsdecode(cwd), error_node)
399388
try:
400389
session_node: TestNode | None = build_test_tree(session)
401390
if not session_node:
402391
raise VSCodePytestError(
403392
"Something went wrong following pytest finish, \
404393
no session node was created"
405394
)
406-
post_response(os.fsdecode(cwd), session_node)
395+
send_discovery_message(os.fsdecode(cwd), session_node)
407396
except Exception as e:
408397
ERRORS.append(
409398
f"Error Occurred, traceback: {(traceback.format_exc() if e.__traceback__ else '')}"
@@ -415,7 +404,7 @@ def pytest_sessionfinish(session, exitstatus):
415404
"children": [],
416405
"id_": "",
417406
}
418-
post_response(os.fsdecode(cwd), error_node)
407+
send_discovery_message(os.fsdecode(cwd), error_node)
419408
else:
420409
if exitstatus == 0 or exitstatus == 1:
421410
exitstatus_bool = "success"
@@ -425,7 +414,7 @@ def pytest_sessionfinish(session, exitstatus):
425414
)
426415
exitstatus_bool = "error"
427416

428-
execution_post(
417+
send_execution_message(
429418
os.fsdecode(cwd),
430419
exitstatus_bool,
431420
None,
@@ -823,8 +812,10 @@ def get_node_path(node: Any) -> pathlib.Path:
823812
atexit.register(lambda: __writer.close() if __writer else None)
824813

825814

826-
def execution_post(cwd: str, status: Literal["success", "error"], tests: TestRunResultDict | None):
827-
"""Sends a POST request with execution payload details.
815+
def send_execution_message(
816+
cwd: str, status: Literal["success", "error"], tests: TestRunResultDict | None
817+
):
818+
"""Sends message execution payload details.
828819
829820
Args:
830821
cwd (str): Current working directory.
@@ -836,10 +827,10 @@ def execution_post(cwd: str, status: Literal["success", "error"], tests: TestRun
836827
)
837828
if ERRORS:
838829
payload["error"] = ERRORS
839-
send_post_request(payload)
830+
send_message(payload)
840831

841832

842-
def post_response(cwd: str, session_node: TestNode) -> None:
833+
def send_discovery_message(cwd: str, session_node: TestNode) -> None:
843834
"""
844835
Sends a POST request with test session details in payload.
845836
@@ -855,7 +846,7 @@ def post_response(cwd: str, session_node: TestNode) -> None:
855846
}
856847
if ERRORS is not None:
857848
payload["error"] = ERRORS
858-
send_post_request(payload, cls_encoder=PathEncoder)
849+
send_message(payload, cls_encoder=PathEncoder)
859850

860851

861852
class PathEncoder(json.JSONEncoder):
@@ -878,7 +869,6 @@ def send_post_request(
878869
payload -- the payload data to be sent.
879870
cls_encoder -- a custom encoder if needed.
880871
"""
881-
print("EJFB into send post request!")
882872
if not TEST_RUN_PIPE:
883873
error_msg = (
884874
"PYTEST ERROR: TEST_RUN_PIPE is not set at the time of pytest starting. "
@@ -893,10 +883,8 @@ def send_post_request(
893883

894884
if __writer is None:
895885
try:
896-
print("EJFB attemping writer open")
897886
__writer = open(TEST_RUN_PIPE, "w", encoding="utf-8", newline="\r\n") # noqa: SIM115, PTH123
898887
except Exception as error:
899-
print("EJFB error in writer open")
900888
error_msg = f"Error attempting to connect to extension named pipe {TEST_RUN_PIPE}[vscode-pytest]: {error}"
901889
print(error_msg, file=sys.stderr)
902890
print(
@@ -913,16 +901,11 @@ def send_post_request(
913901
"params": payload,
914902
}
915903
data = json.dumps(rpc, cls=cls_encoder)
916-
print(f"EJFB Plugin info[vscode-pytest]: sending data: \n{data}\n")
917904
try:
918905
if __writer:
919906
request = f"""content-length: {len(data)}\ncontent-type: application/json\n\n{data}"""
920907
__writer.write(request)
921908
__writer.flush()
922-
print(
923-
f"EJFB Plugin info[vscode-pytest]: data sent successfully[vscode-pytest]: \n{data}\n"
924-
)
925-
# __writer.close()
926909
else:
927910
print(
928911
f"Plugin error connection error[vscode-pytest], writer is None \n[vscode-pytest] data: \n{data} \n",

src/client/common/pipes/namedPipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export async function createReaderPipe(pipeName: string, token?: CancellationTok
166166
deferred.resolve(combined);
167167
return deferred.promise;
168168
}
169-
// linux implementation of FIFO
169+
// mac/linux implementation of FIFO
170170
await mkfifo(pipeName);
171171
const reader = fs.createReadStream(pipeName, {
172172
encoding: 'utf-8',

0 commit comments

Comments
 (0)