Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

allow to run --collect-only without setting up databases #273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions django_nose/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ def run_tests(self, test_labels, extra_tests=None):
if self.verbosity >= 1:
print(' '.join(nose_argv))

self._collect_only = '--collect-only' in nose_argv

result = self.run_suite(nose_argv)
# suite_result expects the suite as the first argument. Fake it.
return self.suite_result({}, result)
Expand Down Expand Up @@ -532,6 +534,9 @@ def _get_models_for_connection(self, connection):

def setup_databases(self):
"""Setup databases, skipping DB creation if requested and possible."""
if self._collect_only:
return

for alias in connections:
connection = connections[alias]
creation = connection.creation
Expand Down Expand Up @@ -591,6 +596,8 @@ def setup_databases(self):

def teardown_databases(self, *args, **kwargs):
"""Leave those poor, reusable databases alone if REUSE_DB is true."""
if self._collect_only:
return
if not _reusing_db():
return super(NoseTestSuiteRunner, self).teardown_databases(
*args, **kwargs)
Expand Down