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

nested conftest not found on Windows #198

Closed
pytestbot opened this issue Oct 5, 2012 · 6 comments
Closed

nested conftest not found on Windows #198

pytestbot opened this issue Oct 5, 2012 · 6 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco)


In the [[https://bitbucket.org/yougov/pmxbot|pmxbot project]], there is a pytest test suite, and within that test suite are two conftest.py files, one at tests/conftest.py and another at tests/unit/conftest.py.

PS C:\Users\jaraco\G\public\pmxbot> tree /f tests
│   conftest.py
│   __init__.py
│
├───functional
│   │   test_exceptions.py
│   │   test_logging.py
│   │   test_messages.py
│   │   test_rss.py
│   │   __init__.py
│   │
│   ...
│
└───unit
        conftest.py
        testconf.yaml
        test_commands.py
        test_karma.py
        test_quotes.py
        test_util.py
        __init__.py

These tests run fine under pytest 2.2.4, but under 2.3.dev10 and 2.3.dev17, some tests fail. Specifically, the tests that depend on the funcarg as defined in [[/yougov/pmxbot/src/85020053dd0b/tests/unit/conftest.py|tests/unit/conftest.py]] will fail because the funcarg is not defined:

PS C:\Users\jaraco\G\public\pmxbot> py.test -k MongoDBKarma -x
============================= test session starts =============================
platform win32 -- Python 2.7.3 -- pytest-2.3.0.dev17 -- C:\Python\python.exe
collected 219 items

tests\unit\test_karma.py:21: TestMongoDBKarma.test_basic_usage ERROR

=================================== ERRORS ====================================
_____________ ERROR at setup of TestMongoDBKarma.test_basic_usage _____________

    def test_basic_usage(self, mongodb_uri):
        LookupError: no factory found for argument 'mongodb_uri'
        available funcargs: pytestconfig, recwarn, monkeypatch, capfd, capsys, tmpdir
        use 'py.test --funcargs [testpath]' for help on them.

C:\Users\jaraco\G\public\pmxbot\tests\unit\test_karma.py:21
!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!!
================== 215 tests deselected by '-kMongoDBKarma' ===================
=================== 215 deselected, 1 error in 4.49 seconds ===================

I read the changelog for changes between 2.2 and 2.3 and I didn't see anything that seemed to indicate that this pattern is no longer supported.

Can pytest support multiple, scoped conftest.py modules? I wanted to report this as it appears to be a regression from 2.2. The changelog should probably mention it (or if it already does, highlight the impact as I've described) if it is not supported. Do you have any other suggestions?


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


This looks like a bug that should be fixed.

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


I am using dev18 (which i just uploaded) and checked out pmxbot, installed jaraco.test and ran with dev18. seems everything passes except for a Connection timeout. Can you confirm?

@pytestbot
Copy link
Contributor Author

Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco):


Unfortunately, I'm still getting the error about the fixture:

{{{
PS C:\Users\jaraco\G\public\pmxbot> py.test -k MongoDBKarma -x
============================= test session starts =============================
platform win32 -- Python 2.7.3 -- pytest-2.3.0.dev18 -- C:\Python\python.exe
collected 219 items

tests\unit\test_karma.py:21: TestMongoDBKarma.test_basic_usage ERROR

=================================== ERRORS ====================================
_____________ ERROR at setup of TestMongoDBKarma.test_basic_usage _____________
file C:\Users\jaraco\G\public\pmxbot\tests\unit\test_karma.py, line 21
def test_basic_usage(self, mongodb_uri):
fixture 'mongodb_uri' not found
available fixtures: pytestconfig, recwarn, monkeypatch, capfd, capsys, tmpdir
use 'py.test --fixtures [testpath]' for help on them.

C:\Users\jaraco\G\public\pmxbot\tests\unit\test_karma.py:21
!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!!
================== 215 tests deselected by '-kMongoDBKarma' ===================
=================== 215 deselected, 1 error in 4.55 seconds ===================
}}}

@pytestbot
Copy link
Contributor Author

Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco):


It appears the issue is unique to Windows. I ran the same test on my Ubuntu Precise box and it runs just fine.

Furthermore, I found I was able to reproduce the issue with a very simple test layout, which I've uploaded to [[/jaraco/pytest-issue198|this repo]]. Run the latest py.test on that repo on Windows and you get the error "fixture 'myarg' not found".

I know Windows issues are a pain, so I'll see what else I can do to help. Perhaps you could refer me to places in the code where the conftest discovery happens, and I could review it with this bug in mind.

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue198 - detection of fixtures from conftest.py files in deeper nested dir structures with certain invocations

@pytestbot
Copy link
Contributor Author

Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco):


Thanks Holger!

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
mgorny pushed a commit to mgorny/pytest that referenced this issue May 27, 2023
…ongo-client-close

pytest-server-fixtures: Explicitly close initial Mongo client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant