diff options
| author | Дилян Палаузов <Dilyan.Palauzov@db.com> | 2018-01-03 18:52:12 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-03 20:12:23 -0500 |
| commit | d7b2aa24f75434c2ce50100cfef3586071e0747a (patch) | |
| tree | 9074eb7522888e744f948c52174f367a4281c200 /tests | |
| parent | c2d0f8c084456b5073252a91eeb09ab3d7453b18 (diff) | |
Fixed #28982 -- Simplified code with and/or.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/auth_tests/test_auth_backends.py | 4 | ||||
| -rw-r--r-- | tests/fixtures/tests.py | 3 | ||||
| -rw-r--r-- | tests/gis_tests/test_data.py | 5 | ||||
| -rw-r--r-- | tests/multiple_database/routers.py | 4 |
4 files changed, 4 insertions, 12 deletions
diff --git a/tests/auth_tests/test_auth_backends.py b/tests/auth_tests/test_auth_backends.py index 86d535703d..390d26ea9b 100644 --- a/tests/auth_tests/test_auth_backends.py +++ b/tests/auth_tests/test_auth_backends.py @@ -339,9 +339,7 @@ class SimpleRowlevelBackend: return False def has_module_perms(self, user, app_label): - if not user.is_anonymous and not user.is_active: - return False - return app_label == "app1" + return (user.is_anonymous or user.is_active) and app_label == 'app1' def get_all_permissions(self, user, obj=None): if not obj: diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py index 4bdaeefbb0..f5df67a55b 100644 --- a/tests/fixtures/tests.py +++ b/tests/fixtures/tests.py @@ -51,8 +51,7 @@ class DumpDataAssertMixin: natural_foreign_keys=False, natural_primary_keys=False, use_base_manager=False, exclude_list=[], primary_keys=''): new_io = StringIO() - if filename: - filename = os.path.join(tempfile.gettempdir(), filename) + filename = filename and os.path.join(tempfile.gettempdir(), filename) management.call_command('dumpdata', *args, **{'format': format, 'stdout': new_io, 'stderr': new_io, diff --git a/tests/gis_tests/test_data.py b/tests/gis_tests/test_data.py index c1e1f5efec..dca847e8cb 100644 --- a/tests/gis_tests/test_data.py +++ b/tests/gis_tests/test_data.py @@ -62,10 +62,7 @@ class TestGeom(TestObj): self.coords = tuplize(coords) if centroid: self.centroid = tuple(centroid) - if ext_ring_cs: - ext_ring_cs = tuplize(ext_ring_cs) - self.ext_ring_cs = ext_ring_cs - + self.ext_ring_cs = ext_ring_cs and tuplize(ext_ring_cs) super().__init__(**kwargs) diff --git a/tests/multiple_database/routers.py b/tests/multiple_database/routers.py index cb12a907c9..7891e22969 100644 --- a/tests/multiple_database/routers.py +++ b/tests/multiple_database/routers.py @@ -43,9 +43,7 @@ class AuthRouter: def allow_relation(self, obj1, obj2, **hints): "Allow any relation if a model in Auth is involved" - if obj1._meta.app_label == 'auth' or obj2._meta.app_label == 'auth': - return True - return None + return obj1._meta.app_label == 'auth' or obj2._meta.app_label == 'auth' or None def allow_migrate(self, db, app_label, **hints): "Make sure the auth app only appears on the 'other' db" |
