Skip to content

Commit

Permalink
Fix warning when dependencies.yaml doesn't exist (#35)
Browse files Browse the repository at this point in the history
The warning was accidentally being issued with a tuple instead of a
string. Fix.
  • Loading branch information
KyleFromNVIDIA authored May 17, 2024
1 parent 1e918c6 commit ca51a32
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
4 changes: 2 additions & 2 deletions rapids_build_backend/impls.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def _edit_pyproject(config):
except FileNotFoundError:
msg = (
f"File not found: '{config.dependencies_file}'. If you want "
"rapids-build-backend to consider dependencies from a dependencies file, ",
"supply an existing file via config setting 'dependencies-file'.",
"rapids-build-backend to consider dependencies from a dependencies file, "
"supply an existing file via config setting 'dependencies-file'."
)
warnings.warn(msg, stacklevel=2)
parsed_config = None
Expand Down
41 changes: 26 additions & 15 deletions tests/test_impls.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ def test_edit_pyproject(
"rapids_build_backend.impls._get_cuda_suffix",
_get_cuda_suffix.__wrapped__,
):
with _edit_pyproject(config):
with open("pyproject.toml") as f:
if write_dependencies_file:
if write_dependencies_file:
with _edit_pyproject(config):
with open("pyproject.toml") as f:
assert f.read() == dedent(
f"""\
[project]
Expand All @@ -288,19 +288,30 @@ def test_edit_pyproject(
"""`rapids-dependency-file-generator`.
"""
)
else:
assert f.read() == dedent(
f"""\
[project]
name = "test-project{cuda_suffix}"
dependencies = []
with open(".pyproject.toml.rapids-build-backend.bak") as f:
assert f.read() == original_contents
else:
with pytest.warns(
UserWarning,
match=rf"^File not found: '{dependencies_file}'\. If you want "
"rapids-build-backend to consider dependencies from a dependencies "
"file, supply an existing file via config setting "
r"'dependencies-file'\.$",
):
with _edit_pyproject(config):
with open("pyproject.toml") as f:
assert f.read() == dedent(
f"""\
[project]
name = "test-project{cuda_suffix}"
dependencies = []
[build-system]
requires = []
"""
)
with open(".pyproject.toml.rapids-build-backend.bak") as f:
assert f.read() == original_contents
[build-system]
requires = []
"""
)
with open(".pyproject.toml.rapids-build-backend.bak") as f:
assert f.read() == original_contents

with open("pyproject.toml") as f:
assert f.read() == original_contents

0 comments on commit ca51a32

Please sign in to comment.