Skip to content

teardown_class not being run #5201

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

Closed
jaraco opened this issue May 3, 2019 · 5 comments
Closed

teardown_class not being run #5201

jaraco opened this issue May 3, 2019 · 5 comments
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@jaraco
Copy link
Contributor

jaraco commented May 3, 2019

I've started to notice after running the tests for pmxbot that some of the files that are meant to be deleted ('tests/functional/testconf.yaml', 'sqllite.sqllite') are lingering on the file system.

The teardown_class methods are supposed to be cleaning up those things, and they used to, but now they're not, likely due to an update of pytest.

Here's the pip list:

pmxbot master $ .tox/python/bin/pip list                                                                                                                                       
Package                       Version                Location                           
----------------------------- ---------------------- -----------------------------------
atomicwrites                  1.3.0                  
attrs                         19.1.0                 
backports.functools-lru-cache 1.5                    
backports.method-request      1.2                    
backports.unittest-mock       1.4                    
beautifulsoup4                4.7.1                  
certifi                       2019.3.9               
chardet                       3.0.4                  
cheroot                       6.5.5                  
CherryPy                      18.1.1                 
docutils                      0.14                   
entrypoints                   0.3                    
feedparser                    5.2.1                  
flake8                        3.7.7                  
future-fstrings               1.1.0                  
idna                          2.8                    
importlib-metadata            0.9                    
importlib-resources           1.0.2                  
inflect                       2.1.0                  
irc                           15.1.1                 
jaraco.apt                    2.0                    
jaraco.classes                2.0                    
jaraco.collections            2.0                    
jaraco.compat                 3.0                    
jaraco.context                2.0                    
jaraco.functools              2.0                    
jaraco.itertools              4.4.2                  
jaraco.logging                2.0                    
jaraco.mongodb                10.3.0                 
jaraco.services               3.0                    
jaraco.stream                 2.0                    
jaraco.text                   3.0                    
jaraco.ui                     2.0.1                  
Jinja2                        2.10.1                 
MarkupSafe                    1.1.1                  
mccabe                        0.6.1                  
more-itertools                7.0.0                  
path.py                       12.0.1                 
pip                           19.0.3                 
pluggy                        0.9.0                  
pmxbot                        1122.9.1.dev5+g79e8264 /Users/jaraco/code/yg/public/pmxbot
portend                       2.4                    
py                            1.8.0                  
pycodestyle                   2.5.0                  
pyflakes                      2.1.1                  
pymongo                       3.8.0                  
pytest                        4.4.1                  
pytest-checkdocs              1.2.0                  
pytest-flake8                 1.0.4                  
python-dateutil               2.8.0                  
pytimeparse                   1.1.8                  
pytz                          2019.1                 
PyYAML                        5.1                    
requests                      2.21.0                 
setuptools                    41.0.1                 
setuptools-scm                3.2.0                  
six                           1.12.0                 
soupsieve                     1.9.1                  
tempora                       1.14.1                 
urllib3                       1.24.3                 
wheel                         0.33.1                 
wordnik-py3                   2.1.2                  
yg.lockfile                   2.3                    
zc.lockfile                   1.4                    
zipp                          0.4.0                  

I've added a "raise ValueError()" into the teardown_class methods (such as this one), but no error occurs during the test run, so I suspect that pytest is somehow no longer honoring teardown_class.

Perhaps something was changed that causes teardown_class to only be honored for the test classes themselves (and not their base classes). I hope to do more investigation later.

@jaraco
Copy link
Contributor Author

jaraco commented May 3, 2019

I attempted to recreate the issue with a simple test, but was unable, so there's something else going on that I don't yet understand.

@nicoddemus
Copy link
Member

Hi @jaraco,

Thanks. We do have tests for teardown_class functionality (as expected 😉), so if you can come up with an example it would be great. 👍

@nicoddemus nicoddemus added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label May 4, 2019
@blueyed
Copy link
Contributor

blueyed commented Jul 29, 2019

JFI: there are issues reported by users of pytest-django also in this regard (caused by pytest handling unittests more itself now). The latest one being pytest-dev/pytest-django#753, with some references to others.

@blueyed
Copy link
Contributor

blueyed commented Oct 18, 2019

@jaraco
Any chance you were using --pdb (#5996).

@jaraco
Copy link
Contributor Author

jaraco commented Oct 19, 2019

I wasn't using --pdb, but I've since figured out the issue. The setup was causing a pytest.skip, so of course the teardown wasn't run. So it was an issue with the package's test suite. Now teardown_class is being called again and all is well. There's no issue with pytest.

@jaraco jaraco closed this as completed Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants