Skip to content

Commit

Permalink
[ADD] Levels
Browse files Browse the repository at this point in the history
  • Loading branch information
abbasidaniyal committed Apr 8, 2021
1 parent c911189 commit 8b221a2
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions django/test/runner.py
Expand Up @@ -581,8 +581,18 @@ def add_arguments(cls, parser):
),
)

def log(self, msg, level=2):
if self.verbosity >= level:
def log(self, msg, level=None):
if level is None:
level = logging.INFO

if self.verbosity == 0:
logging_level = logging.NOTSET
elif self.verbosity == 1:
logging_level = logging.INFO
else:
logging_level = logging.DEBUG

if logging_level >= level:
print(msg)

def setup_test_environment(self, **kwargs):
Expand Down Expand Up @@ -627,9 +637,9 @@ def build_suite(self, test_labels=None, extra_tests=None, **kwargs):

if self.tags or self.exclude_tags:
if self.tags:
self.log('Including test tag(s): %s.' % ', '.join(sorted(self.tags)), level=2)
self.log('Including test tag(s): %s.' % ', '.join(sorted(self.tags)))
if self.exclude_tags:
self.log('Excluding test tag(s): %s.' % ', '.join(sorted(self.exclude_tags)), level=2)
self.log('Excluding test tag(s): %s.' % ', '.join(sorted(self.exclude_tags)))
all_tests = filter_tests_by_tags(all_tests, self.tags, self.exclude_tags)

all_tests = reorder_tests(all_tests, self.reorder_by, self.reverse)
Expand Down Expand Up @@ -719,7 +729,10 @@ def get_databases(self, suite):

unused_databases = [alias for alias in connections if alias not in databases]
if unused_databases:
self.log('Skipping setup of unused database(s): %s.' % ', '.join(sorted(unused_databases)), level=2)
self.log(
'Skipping setup of unused database(s): %s.' % ', '.join(sorted(unused_databases)),
level=logging.DEBUG
)
return databases

def run_tests(self, test_labels, extra_tests=None, **kwargs):
Expand Down

0 comments on commit 8b221a2

Please sign in to comment.