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

pytest run fails on Defining 'pytest_plugins' in a non-top-level conftest is no longer supported #108

Closed
mbukatov opened this issue May 28, 2019 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@mbukatov
Copy link
Contributor

Pytest run fails on Defining 'pytest_plugins' in a non-top-level conftest is no longer supported:

(venv) [ocsqe@localhost ocs-ci]$ python -m pytest -m deployment --cluster-name mbukatov-ocsqe                                                                 
==================================================================== test session starts =====================================================================
platform linux -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0 -- /home/ocsqe/projects/ocs-ci/venv/bin/python                                          
cachedir: .pytest_cache                                                                                                                                       
rootdir: /home/ocsqe/projects/ocs-ci, inifile: pytest.ini                                                                                                     
plugins: ocs-ci-0.1                                                                                                                                           
collected 0 items / 1 errors                                                                                                                                  
                                                                                                                                                              
=========================================================================== ERRORS ===========================================================================
_______________________________________________________________ ERROR collecting test session ________________________________________________________________
Defining 'pytest_plugins' in a non-top-level conftest is no longer supported because it affects the entire directory tree in a non-explicit way.              
  /home/ocsqe/projects/ocs-ci/unittests/conftest.py                                                                                                           
Please move it to a top level conftest file at the rootdir:                                                                                                   
  /home/ocsqe/projects/ocs-ci                                                                                                                                 
For more information, visit:                                                                                                                                  
  https://docs.pytest.org/en/latest/deprecations.html#pytest-plugins-in-non-top-level-conftest-files                                                          
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================== 1 error in 0.14 seconds ===================================================================
(venv) [ocsqe@localhost ocs-ci]$

This is happening because main pytest run is collecting tests from unittests directory.

@mbukatov mbukatov added the bug Something isn't working label May 28, 2019
@mbukatov mbukatov self-assigned this May 28, 2019
@RazTamir
Copy link
Contributor

Is this blocking only deployment?
I just managed to execute tier 1 without issues

@mbukatov
Copy link
Contributor Author

mbukatov commented May 28, 2019

@RazTamir it happens during collecting phase, it will affect any tests. The problem is visible since merge of #104, which was merged just few hours ago.

Edit: as Petr points out below, if you specify at least tests directory, pytest will collect test cases only there and you won't hit this.

@petr-balogh
Copy link
Member

@mbukatov I see you didn't defined the folder of tests in you command so pytest is taking the ./ as default I think so than it's trying to collect everything under the path. So I think that user have to define the ./tests folder when running pytest to provide the path of tests where we have our tests.

So if you will run
py.test -m deployment --cluster-name mbukatov-ocsqe ./tests do you still see the issue?

@mbukatov
Copy link
Contributor Author

@mbukatov I see you didn't defined the folder of tests in you command so pytest is taking the ./ as default I think so than it's trying to collect everything under the path. So I think that user have to define the ./tests folder when running pytest to provide the path of tests where we have our tests.

You are right that pytest is trying to collect everything in the current directory. That said, making boundaries between unittests and actual tests explicit is a good idea, and I just forgot to make sure it's enforced.

@petr-balogh
Copy link
Member

@mbukatov what do you propose to fix this? I see that boundaries are already defined in different folders which we documented should be used to run with. I think that it's normal from user to have specified test directory/path to be defined.

@mbukatov
Copy link
Contributor Author

@mbukatov what do you propose to fix this?

#109

I see that boundaries are already defined in different folders which we documented should be used to run with. I think that it's normal from user to have specified test directory/path to be defined.

Correct. It will just make pytest more resilient to such errors, esp. for deployment.

vasukulkarni pushed a commit that referenced this issue May 28, 2019
@mbukatov
Copy link
Contributor Author

Fixed by #109

PrasadDesala pushed a commit to PrasadDesala/ocs-ci that referenced this issue May 30, 2019
sidhant-agrawal pushed a commit to sidhant-agrawal/ocs-ci that referenced this issue Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants