diff options
| author | Дилян Палаузов <Dilyan.Palauzov@db.com> | 2018-01-12 09:05:16 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-12 12:44:50 -0500 |
| commit | a38ae914d89809aed6d79337b74a8b31b6d3849a (patch) | |
| tree | 42a8465e37fc02b70d8d3f876d23947acb1a2455 /tests | |
| parent | 4bcec02368b7e5466f64dc17286689b16613c94b (diff) | |
Fixed #28996 -- Simplified some boolean constructs and removed trivial continue statements.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/distapp/tests.py | 6 | ||||
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 9 | ||||
| -rw-r--r-- | tests/messages_tests/base.py | 2 | ||||
| -rwxr-xr-x | tests/runtests.py | 23 |
4 files changed, 14 insertions, 26 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py index e9735de074..67558582dc 100644 --- a/tests/gis_tests/distapp/tests.py +++ b/tests/gis_tests/distapp/tests.py @@ -81,11 +81,7 @@ class DistanceTest(TestCase): # Now performing the `dwithin` queries on a geodetic coordinate system. for dist in au_dists: with self.subTest(dist=dist): - if isinstance(dist, D) and not oracle: - type_error = True - else: - type_error = False - + type_error = isinstance(dist, D) and not oracle if isinstance(dist, tuple): if oracle or spatialite: # Result in meters diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index b271ddf55c..cfd1a7c465 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -17,13 +17,8 @@ def get_max_column_name_length(): for db in settings.DATABASES: connection = connections[db] max_name_length = connection.ops.max_name_length() - if max_name_length is None or connection.features.truncates_names: - continue - else: - if allowed_len is None: - allowed_len = max_name_length - db_alias = db - elif max_name_length < allowed_len: + if max_name_length is not None and not connection.features.truncates_names: + if allowed_len is None or max_name_length < allowed_len: allowed_len = max_name_length db_alias = db diff --git a/tests/messages_tests/base.py b/tests/messages_tests/base.py index faf2713d79..17fe06e2e3 100644 --- a/tests/messages_tests/base.py +++ b/tests/messages_tests/base.py @@ -252,7 +252,7 @@ class BaseTests: def test_middleware_disabled_fail_silently(self): """ When the middleware is disabled, an exception is not raised - if 'fail_silently' = True + if 'fail_silently' is True. """ data = { 'messages': ['Test message %d' % x for x in range(5)], diff --git a/tests/runtests.py b/tests/runtests.py index 350604fd06..0302137dbb 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -85,12 +85,11 @@ def get_test_modules(): for modpath, dirpath in discovery_paths: for f in os.listdir(dirpath): - if ('.' in f or - os.path.basename(f) in SUBDIRS_TO_SKIP or - os.path.isfile(f) or - not os.path.exists(os.path.join(dirpath, f, '__init__.py'))): - continue - modules.append((modpath, f)) + if ('.' not in f and + os.path.basename(f) not in SUBDIRS_TO_SKIP and + not os.path.isfile(f) and + os.path.exists(os.path.join(dirpath, f, '__init__.py'))): + modules.append((modpath, f)) return modules @@ -189,13 +188,11 @@ def setup(verbosity, test_labels, parallel): # if the module (or an ancestor) was named on the command line, or # no modules were named (i.e., run all), import # this module and add it to INSTALLED_APPS. - if not test_labels: - module_found_in_labels = True - else: - module_found_in_labels = any( - # exact match or ancestor match - module_label == label or module_label.startswith(label + '.') - for label in test_labels_set) + module_found_in_labels = not test_labels or any( + # exact match or ancestor match + module_label == label or module_label.startswith(label + '.') + for label in test_labels_set + ) if module_name in CONTRIB_TESTS_TO_APPS and module_found_in_labels: settings.INSTALLED_APPS.append(CONTRIB_TESTS_TO_APPS[module_name]) |
