Hack open function to write files in main thread #4486
Annotations
2 errors and 2 warnings
Run tests:
src/components/Editor/Runners/PythonRunner/PyodideRunner/PyodideWorker.test.js#L110
Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)
Expected: StringMatching /pyodide_http.patch_all()/
Received
1: "
__old_input__ = input
def __patched_input__(prompt=False):
if (prompt):
print(prompt)
return __old_input__()
__builtins__.input = __patched_input__
"
2: "
import basthon
import builtins
import os·
# Save the original open function
_original_open = builtins.open·
def _custom_open(filename, mode=\"r\", *args, **kwargs):
if \"x\" in mode and os.path.exists(filename):
raise FileExistsError(f\"File '{filename}' already exists\")
if \"w\" in mode or \"a\" in mode or \"x\" in mode:
class CustomFile:
def __init__(self, filename):
self.filename = filename
self.content = \"\"·
def write(self, content):
self.content += content
# print(f\"{self.filename} {self.content}\")
basthon.kernel.display_event({ \"display_type\": \"file\", \"filename\": self.filename, \"content\": str({\"filename\": self.filename, \"content\": self.content, \"mode\": mode}) })·
def close(self):
pass·
def __enter__(self):
return self·
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()·
return CustomFile(filename)
else:
return _original_open(filename, mode, *args, **kwargs)·
# Override the built-in open function
builtins.open = _custom_open
"
Number of calls: 2
at Object.toHaveBeenCalledWith (/home/runner/work/editor-ui/editor-ui/src/components/Editor/Runners/PythonRunner/PyodideRunner/PyodideWorker.test.js:110:36)
|
Run tests
Process completed with exit code 1.
|
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
|
The following artifacts were uploaded using a version of actions/upload-artifact that is scheduled for deprecation: "cypress-artifacts".
Please update your workflow to use v4 of the artifact actions.
Learn more: https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/
|
Loading