From d7b2aa24f75434c2ce50100cfef3586071e0747a Mon Sep 17 00:00:00 2001 From: Дилян Палаузов Date: Wed, 3 Jan 2018 18:52:12 -0500 Subject: Fixed #28982 -- Simplified code with and/or. --- django/test/client.py | 3 +-- django/test/html.py | 4 +--- django/test/utils.py | 8 ++------ 3 files changed, 4 insertions(+), 11 deletions(-) (limited to 'django/test') diff --git a/django/test/client.py b/django/test/client.py index 3a163d126f..d69c33f1bd 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -236,8 +236,7 @@ def encode_file(boundary, key, file): if content_type is None: content_type = 'application/octet-stream' - if not filename: - filename = key + filename = filename or key return [ to_bytes('--%s' % boundary), to_bytes('Content-Disposition: form-data; name="%s"; filename="%s"' diff --git a/django/test/html.py b/django/test/html.py index 3ec7d44002..fdedafe76e 100644 --- a/django/test/html.py +++ b/django/test/html.py @@ -69,9 +69,7 @@ class Element: other_value = other_attr if attr != other_attr or value != other_value: return False - if self.children != element.children: - return False - return True + return self.children == element.children def __hash__(self): return hash((self.name,) + tuple(a for a in self.attributes)) diff --git a/django/test/utils.py b/django/test/utils.py index c1c38ca096..1a1b78f34d 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -50,9 +50,7 @@ class Approximate: return repr(self.val) def __eq__(self, other): - if self.val == other: - return True - return round(abs(self.val - other), self.places) == 0 + return self.val == other or round(abs(self.val - other), self.places) == 0 class ContextList(list): @@ -300,9 +298,7 @@ def teardown_databases(old_config, verbosity, parallel=0, keepdb=False): def get_runner(settings, test_runner_class=None): - if not test_runner_class: - test_runner_class = settings.TEST_RUNNER - + test_runner_class = test_runner_class or settings.TEST_RUNNER test_path = test_runner_class.split('.') # Allow for relative paths if len(test_path) > 1: -- cgit v1.3