summaryrefslogtreecommitdiff
path: root/django/test
diff options
context:
space:
mode:
authorДилян Палаузов <Dilyan.Palauzov@db.com>2018-01-03 18:52:12 -0500
committerTim Graham <timograham@gmail.com>2018-01-03 20:12:23 -0500
commitd7b2aa24f75434c2ce50100cfef3586071e0747a (patch)
tree9074eb7522888e744f948c52174f367a4281c200 /django/test
parentc2d0f8c084456b5073252a91eeb09ab3d7453b18 (diff)
Fixed #28982 -- Simplified code with and/or.
Diffstat (limited to 'django/test')
-rw-r--r--django/test/client.py3
-rw-r--r--django/test/html.py4
-rw-r--r--django/test/utils.py8
3 files changed, 4 insertions, 11 deletions
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: