mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Refs #23919 -- Stopped inheriting from object to define new style classes.
This commit is contained in:
parent
a556396339
commit
cecc079168
293 changed files with 512 additions and 514 deletions
|
@ -1,7 +1,7 @@
|
|||
from django.db import DEFAULT_DB_ALIAS
|
||||
|
||||
|
||||
class TestRouter(object):
|
||||
class TestRouter:
|
||||
"""
|
||||
Vaguely behave like primary/replica, but the databases aren't assumed to
|
||||
propagate changes.
|
||||
|
@ -22,7 +22,7 @@ class TestRouter(object):
|
|||
return True
|
||||
|
||||
|
||||
class AuthRouter(object):
|
||||
class AuthRouter:
|
||||
"""
|
||||
Control all database operations on models in the contrib.auth application.
|
||||
"""
|
||||
|
@ -54,7 +54,7 @@ class AuthRouter(object):
|
|||
return None
|
||||
|
||||
|
||||
class WriteRouter(object):
|
||||
class WriteRouter:
|
||||
# A router that only expresses an opinion on writes
|
||||
def db_for_write(self, model, **hints):
|
||||
return 'writer'
|
||||
|
|
|
@ -1529,7 +1529,7 @@ class AuthTestCase(TestCase):
|
|||
self.assertIn('"email": "alice@example.com"', command_output)
|
||||
|
||||
|
||||
class AntiPetRouter(object):
|
||||
class AntiPetRouter:
|
||||
# A router that only expresses an opinion on migrate,
|
||||
# passing pets to the 'other' database
|
||||
|
||||
|
@ -1590,7 +1590,7 @@ class PickleQuerySetTestCase(TestCase):
|
|||
self.assertEqual(qs.db, pickle.loads(pickle.dumps(qs)).db)
|
||||
|
||||
|
||||
class DatabaseReceiver(object):
|
||||
class DatabaseReceiver:
|
||||
"""
|
||||
Used in the tests for the database argument in signals (#13552)
|
||||
"""
|
||||
|
@ -1598,7 +1598,7 @@ class DatabaseReceiver(object):
|
|||
self._database = kwargs['using']
|
||||
|
||||
|
||||
class WriteToOtherRouter(object):
|
||||
class WriteToOtherRouter:
|
||||
"""
|
||||
A router that sends all writes to the other database.
|
||||
"""
|
||||
|
@ -1698,7 +1698,7 @@ class SignalTests(TestCase):
|
|||
self.assertEqual(receiver._database, "other")
|
||||
|
||||
|
||||
class AttributeErrorRouter(object):
|
||||
class AttributeErrorRouter:
|
||||
"A router to test the exception handling of ConnectionRouter"
|
||||
def db_for_read(self, model, **hints):
|
||||
raise AttributeError
|
||||
|
@ -1751,7 +1751,7 @@ class RouterAttributeErrorTestCase(TestCase):
|
|||
b.authors.set([p])
|
||||
|
||||
|
||||
class ModelMetaRouter(object):
|
||||
class ModelMetaRouter:
|
||||
"A router to ensure model arguments are real model classes"
|
||||
def db_for_write(self, model, **hints):
|
||||
if not hasattr(model, '_meta'):
|
||||
|
@ -1785,7 +1785,7 @@ class RouterModelArgumentTestCase(TestCase):
|
|||
person.delete()
|
||||
|
||||
|
||||
class SyncOnlyDefaultDatabaseRouter(object):
|
||||
class SyncOnlyDefaultDatabaseRouter:
|
||||
def allow_migrate(self, db, app_label, **hints):
|
||||
return db == DEFAULT_DB_ALIAS
|
||||
|
||||
|
@ -1828,7 +1828,7 @@ class RouterUsed(Exception):
|
|||
class RouteForWriteTestCase(TestCase):
|
||||
multi_db = True
|
||||
|
||||
class WriteCheckRouter(object):
|
||||
class WriteCheckRouter:
|
||||
def db_for_write(self, model, **hints):
|
||||
raise RouterUsed(mode=RouterUsed.WRITE, model=model, hints=hints)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue