Skip to content

Commit a1be3d6

Browse files
Add tests
1 parent 83ea16e commit a1be3d6

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

pyodide_build/tests/recipe/test_builder.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,29 @@ def test_create_constraints_file_override(tmp_path, dummy_xbuildenv):
203203
assert data[-3:] == ["numpy < 2.0", "pytest == 7.0", "setuptools < 75"], data
204204

205205

206+
def test_create_constraints_file_space_in_path_uri_conversion(
207+
tmp_path, dummy_xbuildenv
208+
):
209+
build_dir_with_spaces = tmp_path / "build dir with spaces"
210+
build_dir_with_spaces.mkdir()
211+
212+
builder = RecipeBuilder.get_builder(
213+
recipe=RECIPE_DIR / "pkg_test_constraint",
214+
build_args=BuildArgs(),
215+
build_dir=build_dir_with_spaces,
216+
)
217+
218+
paths = builder._create_constraints_file(filename="constraints with space.txt")
219+
220+
parts = paths.split()
221+
if len(parts) > 1:
222+
last_part = parts[-1]
223+
if "with%20space" in last_part or last_part.startswith("file://"):
224+
assert True
225+
else:
226+
assert "constraints with space.txt" in last_part
227+
228+
206229
class MockSourceSpec(_SourceSpec):
207230
@pydantic.model_validator(mode="after")
208231
def _check_patches_extra(self) -> Self:

pyodide_build/tests/test_build_env.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,23 @@ def test_wheel_paths(dummy_xbuildenv):
237237
f"{current_version}-none-any",
238238
]
239239
)
240+
241+
242+
def test_create_constraints_file_with_spaces(tmp_path, monkeypatch, reset_cache):
243+
from pyodide_build.build_env import _create_constraints_file
244+
245+
constraints_dir = tmp_path / "path with spaces"
246+
constraints_dir.mkdir()
247+
constraints_file = constraints_dir / "constraints.txt"
248+
constraints_file.write_text("numpy==1.0\n")
249+
250+
def mock_get_build_flag(name):
251+
if name == "PIP_CONSTRAINT":
252+
return str(constraints_file)
253+
254+
monkeypatch.setattr("pyodide_build.build_env.get_build_flag", mock_get_build_flag)
255+
256+
result = _create_constraints_file()
257+
258+
assert result.startswith("file://")
259+
assert "path%20with%20spaces" in result or "path with spaces" in result

0 commit comments

Comments
 (0)