django-nose is a Django test runner that integrates the capabilities of the Nose testing framework into Django's test suite. It provides features like testing only specified apps, running specific test modules/classes/tests, simplifying test discovery by obviating the need for `tests/__init__.py`, and leveraging Nose's plugin ecosystem. Additionally, it offers optional performance enhancements such as fixture bundling, reuse of test databases, and hygienic TransactionTestCases. The library is currently in maintenance mode (version 1.4.7) and was last updated in 2020. For new projects, the maintainers recommend considering `pytest` or `unittest` with Django's native testing framework.
pip install django-noseVerified import paths — ran on the pinned version, not inferred.
To quickly integrate `django-nose`, add `django_nose` to your `INSTALLED_APPS` and set `TEST_RUNNER` in your Django `settings.py` file. You can then run tests using `python manage.py test`. Additional Nose arguments can be specified via the `NOSE_ARGS` setting.
For new projects, consider `pytest` (e.g., `pytest-django`) or Django's `unittest` framework. For existing projects, evaluate migration or proceed with caution, acknowledging limited future support.
Upgrade Django and Python to supported versions (e.g., Django 2.2, Python 3.7) or pin `django-nose` to an older version compatible with your environment.
Use `REUSE_DB=1` with extreme caution. Ensure your `TransactionTestCases` are 'hygienic' (clean up database changes). Always run tests without `REUSE_DB=1` after schema migrations to reinitialize the database.
If experiencing failures with `--with-fixture-bundling`, consider disabling it or subclassing `django_nose.FastFixtureTestCase` only for tests that are confirmed to have no order dependencies. Ensure `setUp` and `tearDown` methods clear any non-database state.
For Django 1.4+ projects, remove the `__init__.py` file from the project's root directory. Ensure any Python files previously in the root are moved to an appropriate application or configuration directory.
Avoid importing models or admin classes directly within `__init__.py` files. Instead, import them within the `ready()` method of your `AppConfig` (e.g., `from django.apps import AppConfig; class WorldConfig(AppConfig): name = 'world'; def ready(self): from .admin import countries`). Alternatively, ensure explicit `app_label` is set for models not within an `INSTALLED_APPS` defined application structure.
Explicitly define a `TEST_NAME` in your database settings to use a file-based SQLite database for testing instead of an in-memory one. For example: `DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', 'TEST': {'NAME': BASE_DIR / 'test_sqlite.db'}}}`.No resource links recorded.