Skip to content

Skip Django setup and manage.py scanning with "pytest --help"#238

Merged
pelme merged 1 commit into
pytest-dev:masterfrom
blueyed:no-error-for-help-and-version
Jul 25, 2015
Merged

Skip Django setup and manage.py scanning with "pytest --help"#238
pelme merged 1 commit into
pytest-dev:masterfrom
blueyed:no-error-for-help-and-version

Conversation

@blueyed

@blueyed blueyed commented May 9, 2015

Copy link
Copy Markdown
Contributor

With pytest --version and pytest --help pytest-django should not
throw an error (ImportError) in case of invalid DSM settings etc.

This removes hooking into pytest_configure altogether, and moves the
late call do _setup_django into the session-scoped autoload fixture instead.

Fixes #235

With `pytest --version` and `pytest --help` pytest-django should not
throw an error (ImportError) in case of invalid DSM settings etc.

This removes hooking into `pytest_configure` altogether, and moves the
late call do `_setup_django` into the session-scoped autoload fixture instead.

Fixes pytest-dev#235
@blueyed blueyed force-pushed the no-error-for-help-and-version branch from 866eacf to 61372a2 Compare May 9, 2015 21:58
@landscape-bot

Copy link
Copy Markdown

Code Health
Code quality remained the same when pulling 61372a2 on blueyed:no-error-for-help-and-version into 1f48ebf on pytest-dev:master.

@blueyed

blueyed commented Jun 9, 2015

Copy link
Copy Markdown
Contributor Author

@pelme
Please review and merge it if it's appropriate.

pelme added a commit that referenced this pull request Jul 25, 2015
Skip Django setup and manage.py scanning with "pytest --help". Thanks @blueyed
@pelme pelme merged commit fe7d280 into pytest-dev:master Jul 25, 2015
@blueyed blueyed deleted the no-error-for-help-and-version branch July 25, 2015 11:07
brianhelba added a commit to brianhelba/pytest-django that referenced this pull request Mar 7, 2026
Previously, `pytest_load_initial_conftests` returned early when `--help` or
`--version` was passed (added by pytest-dev#238), skipping `django.setup()` entirely.
This caused conftest files with top-level Django model imports to fail
with `AppRegistryNotReady`.

Instead of returning early, continue with normal Django initialization, allowing
`--help`/`--version` to return properly when everything is valid.

If Django is somehow invalid (e.g. incorrect `DJANGO_SETTINGS_MODULE`),
add a guard to still return gracefully if `--help`/`--version` is requested.
Running real tests would still fail, but these basic informational arguments
shouldn't be blocked.

Fixes pytest-dev#1152
brianhelba added a commit to brianhelba/pytest-django that referenced this pull request Mar 7, 2026
Previously, `pytest_load_initial_conftests` returned early when `--help` or
`--version` was passed (added by pytest-dev#238), skipping `django.setup()` entirely.
This caused conftest files with top-level Django model imports to fail
with `AppRegistryNotReady`.

Instead of returning early, continue with normal Django initialization, allowing
`--help`/`--version` to return properly when everything is valid.

If Django is somehow invalid (e.g. incorrect `DJANGO_SETTINGS_MODULE`),
add a guard to still return gracefully if `--help`/`--version` is requested.
Running real tests would still fail, but these basic informational arguments
shouldn't be blocked.

Fixes pytest-dev#1152
brianhelba added a commit to brianhelba/pytest-django that referenced this pull request Mar 9, 2026
Previously, `pytest_load_initial_conftests` returned early when `--help` or
`--version` was passed (added by pytest-dev#238), skipping `django.setup()` entirely.
This caused conftest files with top-level Django model imports to fail
with `AppRegistryNotReady`.

Instead of returning early, continue with normal Django initialization, allowing
`--help`/`--version` to return properly when everything is valid.

If Django is somehow invalid (e.g. incorrect `DJANGO_SETTINGS_MODULE`),
add a guard to still return gracefully if `--help`/`--version` is requested.
Running real tests would still fail, but these basic informational arguments
shouldn't be blocked.

Fixes pytest-dev#1152
brianhelba added a commit to brianhelba/pytest-django that referenced this pull request Jun 12, 2026
Previously, `pytest_load_initial_conftests` returned early when `--help` or
`--version` was passed (added by pytest-dev#238), skipping `django.setup()` entirely.
This caused conftest files with top-level Django model imports to fail
with `AppRegistryNotReady`.

Instead of returning early, continue with normal Django initialization, allowing
`--help`/`--version` to return properly when everything is valid.

If Django is somehow invalid (e.g. incorrect `DJANGO_SETTINGS_MODULE`),
add a guard to still return gracefully if `--help`/`--version` is requested.
Running real tests would still fail, but these basic informational arguments
shouldn't be blocked.

Fixes pytest-dev#1152
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make "py.test --help" more friendly if DSM is set, but PYTHONPATH is not

3 participants