diff --git a/_version.py b/_version.py index 34c1db3..8412cb1 100644 --- a/_version.py +++ b/_version.py @@ -1 +1 @@ -__version__ = '1.0.2' \ No newline at end of file +__version__ = '1.0.5' \ No newline at end of file diff --git a/src/pyscripttestutils/PyScriptTestRunner.py b/src/pyscripttestutils/PyScriptTestRunner.py index 45bea43..23d6ec3 100644 --- a/src/pyscripttestutils/PyScriptTestRunner.py +++ b/src/pyscripttestutils/PyScriptTestRunner.py @@ -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), @@ -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): @@ -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): @@ -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__}" @@ -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: diff --git a/tests/utils/test_py_script_test_runner_coverage.py b/tests/utils/test_py_script_test_runner_coverage.py index ce960fb..d778e56 100644 --- a/tests/utils/test_py_script_test_runner_coverage.py +++ b/tests/utils/test_py_script_test_runner_coverage.py @@ -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, {}) @@ -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"], {}) @@ -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, {}) @@ -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], {})