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

Pytest 3.7.1 is not collecting `__init__.py` files #3773

Closed
deeechun opened this Issue Aug 2, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@deeechun

deeechun commented Aug 2, 2018

Hi! I seem to have run into a bug on the latest build. Pytest is not collecting __init__.py files, even after specifying python_files to *.py in pytest.ini. I have all of my test functions named correctly, starting with test_* as well.

Here is a quick example.

Tree:

tests/
├── __init__.py
├── sample
│   ├── __init__.py
│   └── sample_test.py

Command + output:

pytest --collect-only tests/sample/
============================= test session starts ==============================
platform linux -- Python 3.7.0, pytest-3.7.1, py-1.5.4, pluggy-0.7.1
rootdir: /home/deebs/playground/radish_steps, inifile: pytest.ini
collected 1 item                                                               
<Module 'tests/sample/sample_test.py'>
  <Function 'test_sample'>

========================= no tests ran in 0.02 seconds =========================

If you need any more details, please feel free to reach out

@nicoddemus

This comment has been minimized.

Show comment
Hide comment
@nicoddemus

nicoddemus Aug 3, 2018

Member

Thanks for the report @deeechun!

Member

nicoddemus commented Aug 3, 2018

Thanks for the report @deeechun!

@jonozzz

This comment has been minimized.

Show comment
Hide comment
@jonozzz

jonozzz Aug 11, 2018

Wait a minute, maybe I'm not understanding this correctly. Are you expecting it to collect tests from __init__.py? If so, then it's not a regression. pytest==3.6 didn't have this feature either.

What's the contents of tests/sample/__init__.py and what would you expect the output to be?

jonozzz commented Aug 11, 2018

Wait a minute, maybe I'm not understanding this correctly. Are you expecting it to collect tests from __init__.py? If so, then it's not a regression. pytest==3.6 didn't have this feature either.

What's the contents of tests/sample/__init__.py and what would you expect the output to be?

@deeechun

This comment has been minimized.

Show comment
Hide comment
@deeechun

deeechun Aug 16, 2018

Hey @jonozzz, sorry for the late reply. This worked correctly pre 3.7! The contents were something like this:

init.py

def test_something():
    print('##########')
    print('##########')
    print('i've done it!')
    print('##########')
    print('##########')

Tests were collected and run as long as i changed the python_files config option to *.py.

deeechun commented Aug 16, 2018

Hey @jonozzz, sorry for the late reply. This worked correctly pre 3.7! The contents were something like this:

init.py

def test_something():
    print('##########')
    print('##########')
    print('i've done it!')
    print('##########')
    print('##########')

Tests were collected and run as long as i changed the python_files config option to *.py.

@jonozzz

This comment has been minimized.

Show comment
Hide comment
@jonozzz

jonozzz Aug 16, 2018

Ah, you're right. I was missing the python_files setting.

jonozzz commented Aug 16, 2018

Ah, you're right. I was missing the python_files setting.

@nicoddemus nicoddemus closed this in #3797 Aug 25, 2018

@nicoddemus nicoddemus reopened this Aug 25, 2018

@nicoddemus

This comment has been minimized.

Show comment
Hide comment
@nicoddemus

nicoddemus Aug 25, 2018

Member

This was closed but the final code does not contain the fix, reopening.

Member

nicoddemus commented Aug 25, 2018

This was closed but the final code does not contain the fix, reopening.

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 25, 2018

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 25, 2018

@nicoddemus nicoddemus closed this in #3872 Aug 26, 2018

cmccandless added a commit to cmccandless/multisite that referenced this issue Aug 30, 2018

Update pytest to 3.7.4 (#10)
This PR updates [pytest](https://pypi.org/project/pytest) from **3.7.2** to **3.7.4**.



<details>
  <summary>Changelog</summary>
  
  
   ### 3.7.4
   ```
   =========================

Bug Fixes
---------

- `3506 &lt;https://github.com/pytest-dev/pytest/issues/3506&gt;`_: Fix possible infinite recursion when writing ``.pyc`` files.


- `3853 &lt;https://github.com/pytest-dev/pytest/issues/3853&gt;`_: Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used.


- `3883 &lt;https://github.com/pytest-dev/pytest/issues/3883&gt;`_: Fix bad console output when using ``console_output_style=classic``.


- `3888 &lt;https://github.com/pytest-dev/pytest/issues/3888&gt;`_: Fix macOS specific code using ``capturemanager`` plugin in doctests.



Improved Documentation
----------------------

- `3902 &lt;https://github.com/pytest-dev/pytest/issues/3902&gt;`_: Fix pytest.org links
   ```
   
  
  
   ### 3.7.3
   ```
   =========================

Bug Fixes
---------

- `3033 &lt;https://github.com/pytest-dev/pytest/issues/3033&gt;`_: Fixtures during teardown can again use ``capsys`` and ``capfd`` to inspect output captured during tests.


- `3773 &lt;https://github.com/pytest-dev/pytest/issues/3773&gt;`_: Fix collection of tests from ``__init__.py`` files if they match the ``python_files`` configuration option.


- `3796 &lt;https://github.com/pytest-dev/pytest/issues/3796&gt;`_: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer
  package.


- `3816 &lt;https://github.com/pytest-dev/pytest/issues/3816&gt;`_: Fix bug where ``--show-capture=no`` option would still show logs printed during fixture teardown.


- `3819 &lt;https://github.com/pytest-dev/pytest/issues/3819&gt;`_: Fix ``stdout/stderr`` not getting captured when real-time cli logging is active.


- `3843 &lt;https://github.com/pytest-dev/pytest/issues/3843&gt;`_: Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-modules``.


- `3848 &lt;https://github.com/pytest-dev/pytest/issues/3848&gt;`_: Fix bugs where unicode arguments could not be passed to ``testdir.runpytest`` on Python 2.


- `3854 &lt;https://github.com/pytest-dev/pytest/issues/3854&gt;`_: Fix double collection of tests within packages when the filename starts with a capital letter.



Improved Documentation
----------------------

- `3824 &lt;https://github.com/pytest-dev/pytest/issues/3824&gt;`_: Added example for multiple glob pattern matches in ``python_files``.


- `3833 &lt;https://github.com/pytest-dev/pytest/issues/3833&gt;`_: Added missing docs for ``pytester.Testdir``.


- `3870 &lt;https://github.com/pytest-dev/pytest/issues/3870&gt;`_: Correct documentation for setuptools integration.



Trivial/Internal Changes
------------------------

- `3826 &lt;https://github.com/pytest-dev/pytest/issues/3826&gt;`_: Replace broken type annotations with type comments.


- `3845 &lt;https://github.com/pytest-dev/pytest/issues/3845&gt;`_: Remove a reference to issue `568 &lt;https://github.com/pytest-dev/pytest/issues/568&gt;`_ from the documentation, which has since been
  fixed.
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pytest
  - Changelog: https://pyup.io/changelogs/pytest/
  - Homepage: https://docs.pytest.org/en/latest/
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment