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

Glob patterns for multiple python-file patterns fails #3824

Closed
jennirinker opened this Issue Aug 17, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@jennirinker

jennirinker commented Aug 17, 2018

Background

I would like pytest to run all my tests but also my examples to make sure they still run. So I want the python_files to test both test_*.py and example_*.py. I'm trying to use global pattern matching to get pytest to check both, but it doesn't seem to work.

MWE

In my setup.cfg file...

[tool:pytest]
python_files={example,test}_*.py

Now pytest discovers neither test_* or example_*.

pytest and OS

Windows 7 - Miniconda3
pytest: 3.7.1

pip list

simplegeneric 0.8.1
six 1.11.
snowballstemmer 1.2.1
Sphinx 1.7.6
sphinx-fortran 1.0.1
sphinx-rtd-theme 0.4.1
sphinxcontrib-websupport 1.1.0
spyder-kernels 0.2.6
sqlitedict 1.5.0
testflo 1.3.0
topfarm 2.0
tornado 5.1
traitlets 4.3.2
urllib3 1.23
utm 0.4.2
wcwidth 0.1.7
wheel 0.31.
wincertstore 0.2
windIO 0.1

@jennirinker

This comment has been minimized.

Show comment
Hide comment
@jennirinker

jennirinker Aug 17, 2018

Found the solution:
python_files = test_*.py *_test.py testing/*/*.py example_*.py

I'm leaving the issue open, because it might be nice to change the documentation to clarify the usage of spaces in the python_files definition (and that true glob matching doesn't seem to occur).

jennirinker commented Aug 17, 2018

Found the solution:
python_files = test_*.py *_test.py testing/*/*.py example_*.py

I'm leaving the issue open, because it might be nice to change the documentation to clarify the usage of spaces in the python_files definition (and that true glob matching doesn't seem to occur).

@asottile

This comment has been minimized.

Show comment
Hide comment
@asottile

asottile Aug 19, 2018

Member

Your {foo,bar} syntax is not a feature of globs, but of shell expansion.

Member

asottile commented Aug 19, 2018

Your {foo,bar} syntax is not a feature of globs, but of shell expansion.

@nicoddemus

This comment has been minimized.

Show comment
Hide comment
@nicoddemus

nicoddemus Aug 19, 2018

Member

Yep, here are the docs for how Python interprets globs:

https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch

But indeed it would be nice to update the example in the reference docs to add an example on how to use multiple globs. 👍

Member

nicoddemus commented Aug 19, 2018

Yep, here are the docs for how Python interprets globs:

https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch

But indeed it would be nice to update the example in the reference docs to add an example on how to use multiple globs. 👍

@jennirinker

This comment has been minimized.

Show comment
Hide comment
@jennirinker

jennirinker Aug 20, 2018

Oh, cool. TIL. I just went to http://www.globtester.com/ and tried stuff there.

I can add the example and make a pull request. But I think it would make more sense to have an example here and then just a more noob-proof explanation of python glob matching in the reference docs.

Thoughts?

jennirinker commented Aug 20, 2018

Oh, cool. TIL. I just went to http://www.globtester.com/ and tried stuff there.

I can add the example and make a pull request. But I think it would make more sense to have an example here and then just a more noob-proof explanation of python glob matching in the reference docs.

Thoughts?

@nicoddemus

This comment has been minimized.

Show comment
Hide comment
@nicoddemus

nicoddemus Aug 20, 2018

Member

@jennirinker that sounds great!

Member

nicoddemus commented Aug 20, 2018

@jennirinker that sounds great!

jennirinker pushed a commit to jennirinker/pytest that referenced this issue Aug 22, 2018

@jennirinker

This comment has been minimized.

Show comment
Hide comment
@jennirinker

jennirinker Aug 22, 2018

Just made the pull request. Sorry it took so long.

jennirinker commented Aug 22, 2018

Just made the pull request. Sorry it took so long.

@nicoddemus

This comment has been minimized.

Show comment
Hide comment
@nicoddemus

nicoddemus Aug 22, 2018

Member

Not at all, thanks!

Member

nicoddemus commented Aug 22, 2018

Not at all, thanks!

nicoddemus added a commit that referenced this issue Aug 22, 2018

@nicoddemus nicoddemus closed this Aug 22, 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