Skip to content

Path in pytest options distracts pytest.ini discovery #1435

Closed
@matthiasha

Description

@matthiasha
Contributor

Please find the minimal source code example for reproducing in Archive.zip.

Without CLI options, the pytest.ini is found (first assertion in the test passes):

❯❯❯ py.test                             ⏎
================================= test session starts =================================
platform linux2 -- Python 2.7.9, pytest-2.9.0, py-1.4.31, pluggy-0.3.1
rootdir: /Users/mzhafn/tmp/pytest-new, inifile: pytest.ini
collected 1 items

test_test.py F

====================================== FAILURES =======================================
______________________________________ test_test ______________________________________

    def test_test():
        assert pytest.config.option.pytest_ini_option == 'set_value'
>       assert pytest.config.option.cli_option == '../../test.log'
E       assert 'unset' == '../../test.log'
E         - unset
E         + ../../test.log

test_test.py:6: AssertionError
============================== 1 failed in 0.04 seconds ===============================

With a path that is part of a custom py.test CLI option, pytest.ini discovery fails:

❯❯❯ py.test --cli-option ../../test.log
================================= test session starts =================================
platform linux2 -- Python 2.7.9, pytest-2.9.0, py-1.4.31, pluggy-0.3.1
rootdir: /Users/mzhafn, inifile:
collected 1 items

test_test.py F

====================================== FAILURES =======================================
______________________________________ test_test ______________________________________

    def test_test():
>       assert pytest.config.option.pytest_ini_option == 'set_value'
E       assert 'unset' == 'set_value'
E         - unset
E         + set_value

test_test.py:5: AssertionError
============================== 1 failed in 0.04 seconds ===============================

platform linux2 -- Python 2.7.9, pytest-2.9.0, py-1.4.31, pluggy-0.3.1
Linux mzhafn-mb-ubuntu 3.19.0-43-generic #49-Ubuntu SMP Sun Dec 27 19:43:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Distributor ID: Ubuntu
Description: Ubuntu 15.04
Release: 15.04
Codename: vivid

check-manifest (0.31)
devpi-client (2.1.0)
devpi-common (2.0.8)
pip (7.1.2)
pkginfo (1.2.1)
pluggy (0.3.1)
py (1.4.31)
pytest (2.9.0)
requests (2.9.1)
setuptools (20.2.2)
tox (2.3.1)
virtualenv (14.0.6)

Activity

added
type: bugproblem that needs to be addressed
type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog
status: criticalgrave problem or usability issue that affects lots of users
type: regressionindicates a problem that was introduced in a release which was working previously
on Mar 4, 2016
removed
type: regressionindicates a problem that was introduced in a release which was working previously
on Mar 5, 2016
nicoddemus

nicoddemus commented on Mar 5, 2016

@nicoddemus
Member

(Just removed the regression and backward compatibility labels because I see the same failure in 2.8.7)

removed
type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog
on Mar 5, 2016
matthiasha

matthiasha commented on Mar 5, 2016

@matthiasha
ContributorAuthor

We are fine atm with 2.6.4

Bruno Oliveira notifications@github.com schrieb am Sa., 5. März 2016,
20:13:

(Just removed the regression label because I see the same failure in
2.8.7)


Reply to this email directly or view it on GitHub
#1435 (comment).

nicoddemus

nicoddemus commented on Mar 5, 2016

@nicoddemus
Member

Oh so in 2.6.4 you don't have this problem?

matthiasha

matthiasha commented on Mar 5, 2016

@matthiasha
ContributorAuthor

No, but I haven't investigated on 2.6.4. It's our production system and it
is running fine.

IMO it is the determine_root (or so) function of the pytest config class,
which gets a parameter "args" passed in, which are all CLI arguments
instead of just those which point to the tests to be executed.

Sorry, just brain dumping into my phone.

Bruno Oliveira notifications@github.com schrieb am Sa., 5. März 2016,
21:45:

Oh so in 2.6.4 you don't have this problem?


Reply to this email directly or view it on GitHub
#1435 (comment).

matthiasha

matthiasha commented on Mar 7, 2016

@matthiasha
ContributorAuthor

So it is the function determine_setup. The parameter args should not include any custom pytest options, but rather only the path(s) to the test(s).

diegorusso

diegorusso commented on Jul 23, 2016

@diegorusso
Contributor

I've just tested pull request #1621 and it fixes this issues.

nicoddemus

nicoddemus commented on Jul 23, 2016

@nicoddemus
Member

@diegorusso thanks for testing this! 😁

465 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: criticalgrave problem or usability issue that affects lots of userstype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @RonnyPfannschmidt@diegorusso@nicoddemus@matthiasha

        Issue actions

          Path in pytest options distracts pytest.ini discovery · Issue #1435 · pytest-dev/pytest