Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion _version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.2'
__version__ = '1.0.5'
10 changes: 5 additions & 5 deletions src/pyscripttestutils/PyScriptTestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _call_typescript_function(
request = {"method": function_name, "args": args, "mocks": mocks}

result = subprocess.run(
["node", str(self.ts_bridge_path), json.dumps(request)],
["node", str(self.ts_bridge_path), json.dumps(request, ensure_ascii=False).encode('utf-8')],
capture_output=True,
text=True,
cwd=str(self.package_root),
Expand Down Expand Up @@ -306,7 +306,7 @@ def compare_results(self, py_result: Any, ts_result: Any) -> bool:
if py_result != ts_result:
return False

if type(py_result) != type(ts_result):
if type(py_result) is not type(ts_result):
return False

if isinstance(py_result, dict) and isinstance(ts_result, dict):
Expand Down Expand Up @@ -335,7 +335,7 @@ def _compare_dicts(self, py_result: Dict[str, Any], ts_result: Dict[str, Any]) -
py_value = py_result[key]
ts_value = ts_result[key]

if type(py_value) != type(ts_value):
if type(py_value) is not type(ts_value):
return False

if isinstance(py_value, dict) and isinstance(ts_value, dict) and not self.compare_results(py_value, ts_value):
Expand Down Expand Up @@ -380,7 +380,7 @@ def assert_strict_parity(self, py_result: Any, ts_result: Any, context: str = ""
if py_result != ts_result or not self.compare_results(py_result, ts_result):
error_details.append(f"Value mismatch: Python={py_result}, TypeScript={ts_result}")

if type(py_result) != type(ts_result):
if type(py_result) is not type(ts_result):
error_details.append(
f"Type mismatch: Python={type(py_result).__name__}, "
f"TypeScript={type(ts_result).__name__}"
Expand All @@ -400,7 +400,7 @@ def assert_strict_parity(self, py_result: Any, ts_result: Any, context: str = ""
error_details.append(f"Fields missing in Python: {missing_in_py}")

for key in py_keys & ts_keys:
if type(py_result[key]) != type(ts_result[key]):
if type(py_result[key]) is not type(ts_result[key]):
error_details.append(f"Field '{key}' type mismatch: Python={type(py_result[key]).__name__}, TypeScript={type(ts_result[key]).__name__}")

if len(error_details) == 0:
Expand Down
8 changes: 4 additions & 4 deletions tests/utils/test_py_script_test_runner_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def test_call_typescript_stderr_triggers_debug_banner(self, capsys):
mock_proc = Mock(
returncode=0,
stderr="console.log debug info",
stdout=json.dumps({"success": True, "result": 50}),
stdout=json.dumps({"success": True, "result": 50}, ensure_ascii=False).encode('utf-8'),
)
with patch(SUBPROCESS_PATH, return_value=mock_proc):
result = runner._call_typescript_function("multiplyByTen", 5, {})
Expand All @@ -296,7 +296,7 @@ def test_call_typescript_success_applies_serializer_and_deserializer(self):
mock_proc = Mock(
returncode=0,
stderr="",
stdout=json.dumps({"success": True, "result": {"value": 1, "myName": "a"}}),
stdout=json.dumps({"success": True, "result": {"value": 1, "myName": "a"}}, ensure_ascii=False).encode('utf-8'),
)
with patch(SUBPROCESS_PATH, return_value=mock_proc):
result = runner._call_typescript_function("createCustomClass", [1, "a"], {})
Expand All @@ -310,7 +310,7 @@ def test_call_typescript_scalar_input_wrapped_in_list(self):

def fake_run(cmd, **_kwargs):
captured["args"] = json.loads(cmd[2])["args"]
return Mock(returncode=0, stderr="", stdout=json.dumps({"success": True, "result": 50}))
return Mock(returncode=0, stderr="", stdout=json.dumps({"success": True, "result": 50}, ensure_ascii=False).encode('utf-8'))

with patch(SUBPROCESS_PATH, side_effect=fake_run):
runner._call_typescript_function("multiplyByTen", 5, {})
Expand Down Expand Up @@ -344,7 +344,7 @@ def test_call_typescript_ts_pack_input_wraps_list_into_single_arg(self):

def fake_run(cmd, **_kwargs):
captured["args"] = json.loads(cmd[2])["args"]
return Mock(returncode=0, stderr="", stdout=json.dumps({"success": True, "result": 30}))
return Mock(returncode=0, stderr="", stdout=json.dumps({"success": True, "result": 30}, ensure_ascii=False).encode('utf-8'))

with patch(SUBPROCESS_PATH, side_effect=fake_run):
runner._call_typescript_function("multiplyByTen", [3], {})
Expand Down
Loading