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

Fixtures missing in 0.1.6? #12

Closed
caarmen opened this issue Jul 20, 2024 · 4 comments
Closed

Fixtures missing in 0.1.6? #12

caarmen opened this issue Jul 20, 2024 · 4 comments

Comments

@caarmen
Copy link
Contributor

caarmen commented Jul 20, 2024

I noticed errors running tests with pytest after upgrading from 0.1.5 to 0.1.6:

E       fixture 'mocked_session' not found

Instead of sharing a full project having the issue, the problem can be seen by installing the package and running pytest --fixtures. This example uses pyenv to create a virtual environment called "test", using python 3.12.4.

pyenv virtualenv-delete test # if the env exists
pyenv virtualenv 3.12.4 test
pyenv activate test
pip install pytest-sqlalchemy-mock==0.1.5 # or 0.1.6
pytest --fixtures
  • With 0.1.5, we see in the logs:
    • plugins: sqlalchemy-mock-0.1.5
    • fixtures defined from pytest_sqlalchemy_mock.base
  • With 0.1.6, this output is missing.

Here's the full output:

For 0.1.5:

=============================================================================================== test session starts ===============================================================================================
platform darwin -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
rootdir: /private/tmp
plugins: sqlalchemy-mock-0.1.5
collected 0 items                                                                                                                                                                                                 
cache -- .../_pytest/cacheprovider.py:560
    Return a cache object that can persist state between testing sessions.

capsysbinary -- .../_pytest/capture.py:1003
    Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.

capfd -- .../_pytest/capture.py:1030
    Enable text capturing of writes to file descriptors ``1`` and ``2``.

capfdbinary -- .../_pytest/capture.py:1057
    Enable bytes capturing of writes to file descriptors ``1`` and ``2``.

capsys -- .../_pytest/capture.py:976
    Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.

doctest_namespace [session scope] -- .../_pytest/doctest.py:738
    Fixture that returns a :py:class:`dict` that will be injected into the
    namespace of doctests.

pytestconfig [session scope] -- .../_pytest/fixtures.py:1338
    Session-scoped fixture that returns the session's :class:`pytest.Config`
    object.

record_property -- .../_pytest/junitxml.py:284
    Add extra properties to the calling test.

record_xml_attribute -- .../_pytest/junitxml.py:307
    Add extra xml attributes to the tag for the calling test.

record_testsuite_property [session scope] -- .../_pytest/junitxml.py:345
    Record a new ``<property>`` tag as child of the root ``<testsuite>``.

tmpdir_factory [session scope] -- .../_pytest/legacypath.py:303
    Return a :class:`pytest.TempdirFactory` instance for the test session.

tmpdir -- .../_pytest/legacypath.py:310
    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:602
    Access and control log capturing.

monkeypatch -- .../_pytest/monkeypatch.py:33
    A convenient fixture for monkey-patching.

recwarn -- .../_pytest/recwarn.py:32
    Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.

tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:242
    Return a :class:`pytest.TempPathFactory` instance for the test session.

tmp_path -- .../_pytest/tmpdir.py:257
    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 pytest_sqlalchemy_mock.base --------------------------------------------------------------------------------
connection_url [session scope] -- ../../Users/calvarez/.pyenv/versions/3.12.4/envs/test/lib/python3.12/site-packages/pytest_sqlalchemy_mock/base.py:14
    no docstring available

engine -- ../../Users/calvarez/.pyenv/versions/3.12.4/envs/test/lib/python3.12/site-packages/pytest_sqlalchemy_mock/base.py:19
    no docstring available

sqlalchemy_declarative_base -- ../../Users/calvarez/.pyenv/versions/3.12.4/envs/test/lib/python3.12/site-packages/pytest_sqlalchemy_mock/base.py:24
    no docstring available

sqlalchemy_mock_config -- ../../Users/calvarez/.pyenv/versions/3.12.4/envs/test/lib/python3.12/site-packages/pytest_sqlalchemy_mock/base.py:29
    no docstring available

connection -- ../../Users/calvarez/.pyenv/versions/3.12.4/envs/test/lib/python3.12/site-packages/pytest_sqlalchemy_mock/base.py:34
    no docstring available

session -- ../../Users/calvarez/.pyenv/versions/3.12.4/envs/test/lib/python3.12/site-packages/pytest_sqlalchemy_mock/base.py:41
    no docstring available

mocked_session -- ../../Users/calvarez/.pyenv/versions/3.12.4/envs/test/lib/python3.12/site-packages/pytest_sqlalchemy_mock/base.py:48
    no docstring available


============================================================================================== no tests ran in 0.16s ==============================================================================================

For 0.1.6:

============================================================================================== test session starts ==============================================================================================
platform darwin -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
rootdir: /private/tmp
collected 0 items                                                                                                                                                                                               
cache -- .../_pytest/cacheprovider.py:560
    Return a cache object that can persist state between testing sessions.

capsysbinary -- .../_pytest/capture.py:1003
    Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.

capfd -- .../_pytest/capture.py:1030
    Enable text capturing of writes to file descriptors ``1`` and ``2``.

capfdbinary -- .../_pytest/capture.py:1057
    Enable bytes capturing of writes to file descriptors ``1`` and ``2``.

capsys -- .../_pytest/capture.py:976
    Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.

doctest_namespace [session scope] -- .../_pytest/doctest.py:738
    Fixture that returns a :py:class:`dict` that will be injected into the
    namespace of doctests.

pytestconfig [session scope] -- .../_pytest/fixtures.py:1338
    Session-scoped fixture that returns the session's :class:`pytest.Config`
    object.

record_property -- .../_pytest/junitxml.py:284
    Add extra properties to the calling test.

record_xml_attribute -- .../_pytest/junitxml.py:307
    Add extra xml attributes to the tag for the calling test.

record_testsuite_property [session scope] -- .../_pytest/junitxml.py:345
    Record a new ``<property>`` tag as child of the root ``<testsuite>``.

tmpdir_factory [session scope] -- .../_pytest/legacypath.py:303
    Return a :class:`pytest.TempdirFactory` instance for the test session.

tmpdir -- .../_pytest/legacypath.py:310
    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:602
    Access and control log capturing.

monkeypatch -- .../_pytest/monkeypatch.py:33
    A convenient fixture for monkey-patching.

recwarn -- .../_pytest/recwarn.py:32
    Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.

tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:242
    Return a :class:`pytest.TempPathFactory` instance for the test session.

tmp_path -- .../_pytest/tmpdir.py:257
    Return a temporary directory path object which is unique to each test
    function invocation, created as a sub directory of the base temporary
    directory.


============================================================================================= no tests ran in 0.08s =============================================================================================
@caarmen
Copy link
Contributor Author

caarmen commented Jul 20, 2024

I did a git bisect between v0.1.5 and v0.1.6.

In each commit tested:

  • build this package from source: python -m build.
  • in the test virtualenv, uninstall pytest-sqlalchemy-mock .
  • in the test virtualenv, install the built whl file from this project's dist/ folder.
  • in the test virtualenv, run pytest --fixtures.

git bisect says this is the first commit where the problem occurs:
52f30f2

@caarmen
Copy link
Contributor Author

caarmen commented Jul 20, 2024

It looks like this change might fix it:

diff --git a/pyproject.toml b/pyproject.toml
index 1e51c10..f960a2d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -68,3 +68,6 @@ norecursedirs = [
     ".eggs",
     "venv",
 ]
+
+[project.entry-points."pytest11"]
+pytest_sqlalchemy_mock = "pytest_sqlalchemy_mock.base"

I'd be happy to open a PR, but I'm not sure what should be the base branch. Looks like the 0.1.6 code hasn't been merged into master yet?

UPDATE: I opened PR #13 based on dev.

@dbt
Copy link

dbt commented Aug 1, 2024

Also running into this issue, thanks for putting up a PR.

@resulyrt93
Copy link
Owner

@caarmen thank you for that great tracing effort and PR. I've just merged it and released new version. 🎉

I also fixed the confusion about the target branch you mentioned, made the default branch master and synced it.

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

3 participants