Skip to content

Default capture hides warnings about skipped dotenv lines #345

Closed

Description

@gaborbernat

A test run can pass after skipping a malformed dotenv line. With default capture the developer sees no diagnostic for the skipped line.

Affected code

Configuration handling at ac5583c

Mechanism

python-dotenv logs a warning during plugin initialization. pytest captures that output before collection and discards it when collection succeeds. Reference

Reproduction

Run at ac5583cb5181 with pytest 9.2.0 in an empty directory on Linux.

printf '[pytest]\nenv_files = .env\n' > pytest.ini
printf 'FINE=yes\nbad line here\n' > .env
printf 'def test_config():\n    import os\n    assert os.environ["FINE"] == "yes"\n' > test_config.py
pytest -q
pytest -q -s

Observed output:

Default capture: 1 passed
With -s: python-dotenv could not parse statement starting at line 2

Show the skipped line number with default capture.

Impact

Easy to reproduce. Exposure is niche because the configured file must contain a malformed line.

Credits

OSS Scanner report ANT-2026-UFQWEJSY.

Activity

  1. added
    bug
    on Nov 19, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions