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

Tests fail because the mocking strategy conflicts with pytest on Nixos #365

Open
ludat opened this issue Jul 22, 2024 · 1 comment
Open

Comments

@ludat
Copy link

ludat commented Jul 22, 2024

I'm trying to build this inside a nixos worker and it keeps failing, After inpecting the code and it looks like the problem appears because one of the assertions inside tests/conftest.py (of os.rename) conflicts with an internal usage inside pytest.

I'm not sure what's causing it but here's the log and building this on nixos mainline is failing now.

Here are the logs:

============================= test session starts ==============================
platform linux -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
rootdir: /build/source
configfile: pyproject.toml
collected 97 items

tests/test_bin_dotbot.py ...                                             [  3%]
tests/test_clean.py ..........                                           [ 13%]
tests/test_cli.py ..........                                             [ 23%]
tests/test_config.py ....                                                [ 27%]
tests/test_create.py ....                                                [ 31%]
tests/test_link.py .................................ss............       [ 80%]
tests/test_noop.py ..                                                    [ 82%]
tests/test_shell.py ................                                     [ 98%]
tests/test_shim.py s                                                     [100%]
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/pytest/__main__.py", line 7, in <module>
    raise SystemExit(pytest.console_main())
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/config/__init__.py", line 206, in console_main
    code = main()
           ^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/config/__init__.py", line 178, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/main.py", line 332, in pytest_cmdline_main
    return wrap_session(config, _main)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/main.py", line 320, in wrap_session
    config.hook.pytest_sessionfinish(
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/logging.py", line 872, in pytest_sessionfinish
    return (yield)
            ^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/terminal.py", line 867, in pytest_sessionfinish
    result = yield
             ^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/warnings.py", line 140, in pytest_sessionfinish
    return (yield)
            ^^^^^
  File "/nix/store/jrc5vsl77kzmwn9d1lm5yrzgn5rg6s12-python3.12-pluggy-1.5.0/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/cacheprovider.py", line 479, in pytest_sessionfinish
    config.cache.set("cache/nodeids", sorted(self.cached_nodeids))
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/cacheprovider.py", line 187, in set
    self._mkdir(path.parent)
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/cacheprovider.py", line 129, in _mkdir
    self._ensure_cache_dir_and_supporting_files()
  File "/nix/store/6m4rxk7rn1ncads8mfjp55hxphzyfr2j-python3.12-pytest-8.2.2/lib/python3.12/site-packages/_pytest/cacheprovider.py", line 232, in _ensure_cache_dir_and_supporting_files
    path.rename(self._cachedir)
  File "/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12/pathlib.py", line 1363, in rename
    os.rename(self, target)
  File "/build/source/tests/conftest.py", line 50, in wrapper
    assert value == os.path.abspath(value), msg
AssertionError: The 'src' argument to os.rename() must be an absolute path
assert PosixPath('/build/source/pytest-cache-files-g3cjced1') == '/build/source/pytest-cache-files-g3cjced1'
 +  where '/build/source/pytest-cache-files-g3cjced1' = <function abspath at 0x7ffff72a5580>(PosixPath('/build/source/pytest-cache-files-g3cjced1'))
 +    where <function abspath at 0x7ffff72a5580> = <module 'posixpath' (frozen)>.abspath
 +      where <module 'posixpath' (frozen)> = os.path

NOTE: I don't really understand why this shows up in nixos but not on the CI

@kurtmckee
Copy link
Contributor

You're running pytest, not tox to invoke the test suite.

Run tox to set up and execute the test suite environment in a supported way.

@anishathalye This ticket can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants