Closed utkarsh2102 closed 1 year ago
OTOH, if I run the tests like:
python3-coverage run -m pytest --fixtures ./flask_dance/fixtures/pytest.py
All the tests are skipped. 😭
Logs for above are:
I: pybuild base:239: python3-coverage run -m pytest --fixtures ./flask_dance/fixtures/pytest.py
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0+repack
rootdir: /<<PKGBUILDDIR>>
plugins: mock-3.8.2, betamax-0.8.1
collected 0 items
cache -- .../_pytest/cacheprovider.py:510
Return a cache object that can persist state between testing sessions.
capsys -- .../_pytest/capture.py:878
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
capsysbinary -- .../_pytest/capture.py:895
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
capfd -- .../_pytest/capture.py:912
Enable text capturing of writes to file descriptors ``1`` and ``2``.
capfdbinary -- .../_pytest/capture.py:929
Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
doctest_namespace [session scope] -- .../_pytest/doctest.py:731
Fixture that returns a :py:class:`dict` that will be injected into the
namespace of doctests.
pytestconfig [session scope] -- .../_pytest/fixtures.py:1334
Session-scoped fixture that returns the session's :class:`pytest.Config`
object.
record_property -- .../_pytest/junitxml.py:282
Add extra properties to the calling test.
record_xml_attribute -- .../_pytest/junitxml.py:305
Add extra xml attributes to the tag for the calling test.
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
tmpdir_factory [session scope] -- .../_pytest/legacypath.py:295
Return a :class:`pytest.TempdirFactory` instance for the test session.
tmpdir -- .../_pytest/legacypath.py:302
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.
caplog -- .../_pytest/logging.py:487
Access and control log capturing.
monkeypatch -- .../_pytest/monkeypatch.py:29
A convenient fixture for monkey-patching.
recwarn -- .../_pytest/recwarn.py:29
Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:184
Return a :class:`pytest.TempPathFactory` instance for the test session.
tmp_path -- .../_pytest/tmpdir.py:199
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.
---------------- fixtures defined from betamax.fixtures.pytest -----------------
betamax_parametrized_recorder -- ../../../usr/lib/python3/dist-packages/betamax/fixtures/pytest.py:110
Generate a recorder with a session that has Betamax already installed.
betamax_parametrized_session -- ../../../usr/lib/python3/dist-packages/betamax/fixtures/pytest.py:137
Generate a session that has Betamax already installed.
betamax_recorder -- ../../../usr/lib/python3/dist-packages/betamax/fixtures/pytest.py:72
Generate a recorder with a session that has Betamax already installed.
betamax_session -- ../../../usr/lib/python3/dist-packages/betamax/fixtures/pytest.py:95
Generate a session that has Betamax already installed.
------------------- fixtures defined from pytest_mock.plugin -------------------
class_mocker [class scope] -- ../../../usr/lib/python3/dist-packages/pytest_mock/plugin.py:407
Return an object that has the same interface to the `mock` module, but
takes care of automatically undoing all patches after each test method.
mocker -- ../../../usr/lib/python3/dist-packages/pytest_mock/plugin.py:407
Return an object that has the same interface to the `mock` module, but
takes care of automatically undoing all patches after each test method.
module_mocker [module scope] -- ../../../usr/lib/python3/dist-packages/pytest_mock/plugin.py:407
Return an object that has the same interface to the `mock` module, but
takes care of automatically undoing all patches after each test method.
package_mocker [package scope] -- ../../../usr/lib/python3/dist-packages/pytest_mock/plugin.py:407
Return an object that has the same interface to the `mock` module, but
takes care of automatically undoing all patches after each test method.
session_mocker [session scope] -- ../../../usr/lib/python3/dist-packages/pytest_mock/plugin.py:407
Return an object that has the same interface to the `mock` module, but
takes care of automatically undoing all patches after each test method.
-------------- fixtures defined from flask_dance.fixtures.pytest ---------------
betamax_record_flask_dance -- flask_dance/fixtures/pytest.py:55
Wraps the specified Flask-Dance sessions with Betamax
============================ no tests ran in 0.23s =============================
Maybe problem is that flask_dance
isn't properly installed when you run the tests? This fixture is installed using the entry_points
system documented here: https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#setuptools-entry-points
You can see the entry point definition in setup.py
and the code itself in flask_dance/fixtures/pytest.py
. Does that help you debug the issue?
Hellu! Thank you very much but these are build-time tests. So these are running whilst building the package and not running in the installed form. :/
The command you posted (python3-coverage run -m pytest
) has nothing to do with building a Python package. It may be part of how Debian builds packages, but that's a different system.
In order to make this test pass, you will need to install the Python package first, which is typically done using pip
. In this case, you can make it an "editable" install, so that pip
links the files from their existing location rather than copying them to the site-packages
directory. Once you install flask_dance
with pip
, the pytest fixtures should be registered and available for tests to use. Does that make sense? I don't know how familiar you are with the Python packaging ecosystem.
Hello,
The command you posted (
python3-coverage run -m pytest
) has nothing to do with building a Python package. It may be part of how Debian builds packages, but that's a different system.
Aah, yes. I should've mentioned that. Debian's build system also includes tests during build time.
In order to make this test pass, you will need to install the Python package first, which is typically done using
pip
. In this case, you can make it an "editable" install, so thatpip
links the files from their existing location rather than copying them to thesite-packages
directory. Once you installflask_dance
withpip
, the pytest fixtures should be registered and available for tests to use. Does that make sense? I don't know how familiar you are with the Python packaging ecosystem.
I do understand that and it makes sense. However, on the Debian side, we have two sorts of testing - during the build time and then in the installed form. The fixture tests don't work during the build time (because those fixtures are not registered and thus not available) but they work just fine when tests are run in the installed form.
So let me paraphrase my question: since they're working fine in the installed form of the package, is there a way to make them work during the build time as well? When the package is not installed. Alternatively, are these fixture tests NOT meant to run during the build time? D'you know if there's a neat way of not running them during build time (that is, some sorta flags passed to pytest or something)?
Hi @singingwolfboy,
So let me paraphrase my question: since they're working fine in the installed form of the package, is there a way to make them work during the build time as well? When the package is not installed. Alternatively, are these fixture tests NOT meant to run during the build time? D'you know if there's a neat way of not running them during build time (that is, some sorta flags passed to pytest or something)?
Slight ping on this one^, please. No rush, I just wanted to ensure this didn't fall through the cracks. I am just trying to get this test sorted for the build-time tests. Let me know if you have any suggestions, opinions, or questions. TIA!
Oops, thanks for the reminder! I just pushed a new version that allows you to run the tests without the ones that require the package to be installed. To do so, run:
pytest -m "not install_required"
# or, if you want to also generate coverage:
coverage run -m pytest -m "not install_required"
The test suite uses pytest marks to accomplish this. Let me know if that works for you, or if you need anything else to make this work!
Hello,
Thank you very much for your work on this! However, whilst trying to package this module for Debian, I seem to run into this test failure around fixtures:
D'you have any idea how to get this working? TIA! \o/