Skip to content

Commit ec24bc2

Browse files
committed
fix: ram tests open mock
1 parent 4731167 commit ec24bc2

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

test/test_tools_ready_to_application_running.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def fake_open(file, mode="r", *args, **kwargs):
3838
return io.BytesIO()
3939
elif "r" in mode:
4040
return io.BytesIO(b"fake zip content")
41+
if isinstance(file, str) and file.startswith("/dev/pts/"):
42+
return io.BytesIO() if "b" in mode else io.StringIO()
4143
return original_open(file, mode, *args, **kwargs)
4244

4345
# Mock file system and subprocess operations
@@ -86,6 +88,8 @@ def fake_open(file, mode="r", *args, **kwargs):
8688
import io
8789

8890
return io.BytesIO()
91+
if isinstance(file, str) and file.startswith("/dev/pts/"):
92+
return io.BytesIO() if "b" in mode else io.StringIO()
8993
return original_open(file, mode, *args, **kwargs)
9094

9195
monkeypatch.setattr("builtins.open", fake_open)
@@ -138,6 +142,8 @@ def fake_open(file, mode="r", *args, **kwargs):
138142
import io
139143

140144
return io.BytesIO()
145+
if isinstance(file, str) and file.startswith("/dev/pts/"):
146+
return io.BytesIO() if "b" in mode else io.StringIO()
141147
return original_open(file, mode, *args, **kwargs)
142148

143149
monkeypatch.setattr("builtins.open", fake_open)

test/test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ def fake_open(file, mode="r", *args, **kwargs):
107107
return io.BytesIO()
108108
elif "r" in mode:
109109
return io.BytesIO(b"fake zip content")
110+
if isinstance(file, str) and file.startswith("/dev/pts/"):
111+
return io.BytesIO() if "b" in mode else io.StringIO()
110112
return original_open(file, mode, *args, **kwargs)
111113

112114
# Mock file system and subprocess operations

0 commit comments

Comments
 (0)