Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Default for Site.platform_path_map errors out #58

Open
MHendricks opened this issue Jul 14, 2023 · 0 comments
Open

[Bug]: Default for Site.platform_path_map errors out #58

MHendricks opened this issue Jul 14, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@MHendricks
Copy link
Member

MHendricks commented Jul 14, 2023

Summary

The default for Site.platform_path_map's platform is None. If you call this it errors out.

Expected Behavior

I think this should use the current platform, or you should be required to pass the platform.

Steps to Reproduce Behavior

The simplest way to reproduce this is to add a missing test where we pass None to platform.

diff --git a/tests/test_site.py b/tests/test_site.py
index 628873d..fb128f2 100644
--- a/tests/test_site.py
+++ b/tests/test_site.py
@@ -318,6 +318,8 @@ class TestPlatformPathMap:
         monkeypatch.setattr(utils, "Platform", utils.LinuxPlatform)
         site = Site([config_root / "site_main.json"])

+        out = site.platform_path_map("/usr/local/host/root", platform=None)
+
         # Check exact path matches are translated
         out = site.platform_path_map("/usr/local/host/root", platform="linux")
         assert out == "/usr/local/host/root"

This error is raised if you run this tox test command: tox -e py37 -- -vv tests/test_site.py --tb native

Traceback (most recent call last):
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\_pytest\runner.py", line 341, in from_call
    result: Optional[TResult] = func()
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\_pytest\runner.py", line 262, in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_hooks.py", line 433, in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_manager.py", line 112, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_callers.py", line 155, in _multicall
    return outcome.get_result()
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_result.py", line 108, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_callers.py", line 80, in _multicall
    res = hook_impl.function(*args)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\_pytest\runner.py", line 177, in pytest_runtest_call
    raise e
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\_pytest\runner.py", line 169, in pytest_runtest_call
    item.runtest()
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\_pytest\python.py", line 1788, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_hooks.py", line 433, in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_manager.py", line 112, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_callers.py", line 116, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\pluggy\_callers.py", line 80, in _multicall
    res = hook_impl.function(*args)
  File "C:\blur\dev\hab_\.tox\py37\lib\site-packages\_pytest\python.py", line 194, in pytest_pyfunc_call
    result = testfunction(**testargs)
  File "C:\blur\dev\hab_\tests\test_site.py", line 321, in test_linux
    out = site.platform_path_map("/usr/local/host/root", platform=None)
  File "C:\blur\dev\hab_\hab\site.py", line 142, in platform_path_map
    relative = path.relative_to(src)
AttributeError: 'NoneType' object has no attribute 'relative_to'

Environment

  • Version: 0.19.0
  • OS: Windows 10
@MHendricks MHendricks added the bug Something isn't working label Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant