Skip to content

Commit 9dcce14

Browse files
committed
fix tests
1 parent b772582 commit 9dcce14

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

tests/test_web/test_module.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,36 @@ def test_module_from_file_source_conflict(tmp_path):
111111
first_file = tmp_path / "first.js"
112112

113113
with pytest.raises(FileNotFoundError, match=r"does not exist"):
114-
reactpy.reactjs.file_to_module("temp", first_file)
114+
reactpy.reactjs.file_to_module(
115+
"test-module-from-file-source-conflict", first_file
116+
)
115117

116118
first_file.touch()
117119

118-
reactpy.reactjs.file_to_module("temp", first_file)
120+
reactpy.reactjs.file_to_module("test-module-from-file-source-conflict", first_file)
119121

120122
second_file = tmp_path / "second.js"
121123
second_file.touch()
122124

123125
# ok, same content
124-
reactpy.reactjs.file_to_module("temp", second_file)
126+
reactpy.reactjs.file_to_module("test-module-from-file-source-conflict", second_file)
125127

126128
third_file = tmp_path / "third.js"
127129
third_file.write_text("something-different")
128130

129131
with assert_reactpy_did_log(r"Existing web module .* will be replaced with"):
130-
reactpy.reactjs.file_to_module("temp", third_file)
132+
reactpy.reactjs.file_to_module(
133+
"test-module-from-file-source-conflict", third_file
134+
)
131135

132136

133137
def test_web_module_from_file_symlink(tmp_path):
134138
file = tmp_path / "temp.js"
135139
file.touch()
136140

137-
module = reactpy.reactjs.file_to_module("temp", file, symlink=True)
141+
module = reactpy.reactjs.file_to_module(
142+
"test-web-module-from-file-symlink", file, symlink=True
143+
)
138144

139145
assert module.file.resolve().read_text() == ""
140146

@@ -147,29 +153,38 @@ def test_web_module_from_file_symlink_twice(tmp_path):
147153
file_1 = tmp_path / "temp_1.js"
148154
file_1.touch()
149155

150-
reactpy.reactjs.file_to_module("temp", file_1, symlink=True)
151-
152-
with assert_reactpy_did_not_log(r"Existing web module .* will be replaced with"):
153-
reactpy.reactjs.file_to_module("temp", file_1, symlink=True)
154-
156+
reactpy.reactjs.file_to_module(
157+
"test-web-module-from-file-symlink-twice", file_1, symlink=True
158+
)
159+
with assert_reactpy_did_not_log(
160+
r"Existing web module 'test-web-module-from-file-symlink-twice.js' will be replaced with"
161+
):
162+
reactpy.reactjs.file_to_module(
163+
"test-web-module-from-file-symlink-twice", file_1, symlink=True
164+
)
155165
file_2 = tmp_path / "temp_2.js"
156166
file_2.write_text("something")
157-
158-
with assert_reactpy_did_log(r"Existing web module .* will be replaced with"):
159-
reactpy.reactjs.file_to_module("temp", file_2, symlink=True)
167+
with assert_reactpy_did_log(
168+
r"Existing web module 'test-web-module-from-file-symlink-twice.js' will be replaced with"
169+
):
170+
reactpy.reactjs.file_to_module(
171+
"test-web-module-from-file-symlink-twice", file_2, symlink=True
172+
)
160173

161174

162175
def test_web_module_from_file_replace_existing(tmp_path):
163176
file1 = tmp_path / "temp1.js"
164177
file1.touch()
165178

166-
reactpy.reactjs.file_to_module("temp", file1)
179+
reactpy.reactjs.file_to_module("test-web-module-from-file-replace-existing", file1)
167180

168181
file2 = tmp_path / "temp2.js"
169182
file2.write_text("something")
170183

171184
with assert_reactpy_did_log(r"Existing web module .* will be replaced with"):
172-
reactpy.reactjs.file_to_module("temp", file2)
185+
reactpy.reactjs.file_to_module(
186+
"test-web-module-from-file-replace-existing", file2
187+
)
173188

174189

175190
def test_module_missing_exports():
@@ -425,12 +440,12 @@ def App():
425440

426441
def test_component_from_string():
427442
reactpy.reactjs.component_from_string(
428-
"old", "Component", resolve_imports=False, name="temp"
443+
"old", "Component", resolve_imports=False, name="test-component-from-string"
429444
)
430445
reactpy.reactjs._STRING_JS_MODULE_CACHE.clear()
431446
with assert_reactpy_did_log(r"Existing web module .* will be replaced with"):
432447
reactpy.reactjs.component_from_string(
433-
"new", "Component", resolve_imports=False, name="temp"
448+
"new", "Component", resolve_imports=False, name="test-component-from-string"
434449
)
435450

436451

0 commit comments

Comments
 (0)