0.15.3: Issues with pytester fixture
dvzrv opened this issue · 6 comments
Hi! When trying to package 0.15.3 on Arch Linux I ran into an issue with the test_plugin
test:
==================================== ERRORS ====================================
________________________ ERROR at setup of test_plugin _________________________
file /build/python-libtmux/src/libtmux-0.15.3/tests/test_pytest_plugin.py, line 8
def test_plugin(
E fixture 'pytester' not found
> available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, clear_env, config_file, doctest_namespace, home_path, home_user_name, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, server, session, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory, user_path, zshrc
> use 'pytest --fixtures [testpath]' for help on them.
/build/python-libtmux/src/libtmux-0.15.3/tests/test_pytest_plugin.py:8
=========================== short test summary info ============================
ERROR tests/test_pytest_plugin.py::test_plugin
========================= 92 passed, 1 error in 8.86s ==========================
We are currently using python-pytest 7.1.3 on Arch Linux and the fixture should be somehow available. According to the pytest documentation it needs to be added in the configuration file. As you do not include your conftest.py in the sdist tarball, the configuration is missing though. FWIW, the conftest file can just reside in the tests directory.
Looking at the import of the internal functionality from _pytest
I don't think it is a good idea to rely on it the way it is currently done. The internal implementations of pytest will change and they will break your tests.
It is much better to from pytest import Pytester
.
I'll look closer after work today (this week, latest) and release a patch at soon as possible
P.S. Are there instructions where I could simulate archlinux packaging / test infrastructure in our GitHub action?
Looking at the import of the internal functionality from _pytest I don't think it is a good idea to rely on it the way it is currently done.
Agreed. It's an oversight on my part. 🙏
FWIW, the conftest file can just reside in the tests directory.
More complicated than that: 10d1f9b
If this becomes an issue I will find a solution for it.
Job: https://github.com/tmux-python/libtmux/actions/runs/3087099287/jobs/4992111137
Log snapshot
2022-09-20T02:55:04.8788354Z ##[group]Run export PATH=$HOME/tmux-builds/tmux-3.1b/bin:$PATH
2022-09-20T02:55:04.8788721Z �[36;1mexport PATH=$HOME/tmux-builds/tmux-3.1b/bin:$PATH�[0m
2022-09-20T02:55:04.8789016Z �[36;1mls $HOME/tmux-builds/tmux-3.1b/bin�[0m
2022-09-20T02:55:04.8789256Z �[36;1mtmux -V�[0m
2022-09-20T02:55:04.8789530Z �[36;1mpoetry run py.test --cov=./ --cov-append --cov-report=xml�[0m
2022-09-20T02:55:04.8844046Z shell: /usr/bin/bash -e {0}
2022-09-20T02:55:04.8844259Z env:
2022-09-20T02:55:04.8844524Z pythonLocation: /opt/hostedtoolcache/Python/3.7.13/x64
2022-09-20T02:55:04.8844868Z PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.7.13/x64/lib/pkgconfig
2022-09-20T02:55:04.8845202Z Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.13/x64
2022-09-20T02:55:04.8845515Z Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.13/x64
2022-09-20T02:55:04.8845822Z Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.13/x64
2022-09-20T02:55:04.8846127Z LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.13/x64/lib
2022-09-20T02:55:04.8846407Z COV_CORE_SOURCE: .
2022-09-20T02:55:04.8846621Z COV_CORE_CONFIG: .coveragerc
2022-09-20T02:55:04.8846862Z COV_CORE_DATAFILE: .coverage.eager
2022-09-20T02:55:04.8847081Z ##[endgroup]
2022-09-20T02:55:04.8932036Z tmux
2022-09-20T02:55:04.8976328Z tmux 3.1b
2022-09-20T02:55:06.8054229Z ============================= test session starts ==============================
2022-09-20T02:55:06.8054856Z collected 0 items / 1 error
2022-09-20T02:55:06.8055240Z
2022-09-20T02:55:06.8055556Z ==================================== ERRORS ====================================
2022-09-20T02:55:06.8055903Z ________________________ ERROR collecting test session _________________________
2022-09-20T02:55:06.8056510Z Defining 'pytest_plugins' in a non-top-level conftest is no longer supported:
2022-09-20T02:55:06.8056899Z It affects the entire test suite instead of just below the conftest as expected.
2022-09-20T02:55:06.8057243Z /home/runner/work/libtmux/libtmux/src/libtmux/conftest.py
2022-09-20T02:55:06.8057581Z Please move it to a top level conftest file at the rootdir:
2022-09-20T02:55:06.8057850Z /home/runner/work/libtmux/libtmux
2022-09-20T02:55:06.8058091Z For more information, visit:
2022-09-20T02:55:06.8058635Z https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-files
2022-09-20T02:55:06.8058929Z
2022-09-20T02:55:06.8059183Z ---------- coverage: platform linux, python 3.7.13-final-0 -----------
2022-09-20T02:55:06.8059496Z Coverage XML written to file coverage.xml
2022-09-20T02:55:06.8059656Z
2022-09-20T02:55:06.8059792Z =========================== short test summary info ============================
2022-09-20T02:55:06.8060021Z ERROR
2022-09-20T02:55:06.8060279Z !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
2022-09-20T02:55:06.8060568Z =============================== 1 error in 0.37s ===============================
2022-09-20T02:55:06.8592928Z ##[error]Process completed with exit code 2.
Markdown
________________________ ERROR collecting test session _________________________
Defining 'pytest_plugins' in a non-top-level conftest is no longer supported:
It affects the entire test suite instead of just below the conftest as expected.
/home/runner/work/libtmux/libtmux/src/libtmux/conftest.py
Please move it to a top level conftest file at the rootdir:
/home/runner/work/libtmux/libtmux
For more information, visit:
https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-files
0.15.4 worked, thanks!