1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Switched setUp() to setUpTestData() where possible in Django's tests.

This commit is contained in:
Simon Charette
2018-11-23 20:59:38 -05:00
committed by Tim Graham
parent 9a7d336c38
commit 84e7a9f4a7
49 changed files with 421 additions and 334 deletions

View File

@@ -6,17 +6,18 @@ from .models import Person
class RecursiveM2MTests(TestCase):
def setUp(self):
self.a, self.b, self.c, self.d = [
@classmethod
def setUpTestData(cls):
cls.a, cls.b, cls.c, cls.d = [
Person.objects.create(name=name)
for name in ["Anne", "Bill", "Chuck", "David"]
]
# Anne is friends with Bill and Chuck
self.a.friends.add(self.b, self.c)
cls.a.friends.add(cls.b, cls.c)
# David is friends with Anne and Chuck - add in reverse direction
self.d.friends.add(self.a, self.c)
cls.d.friends.add(cls.a, cls.c)
def test_recursive_m2m_all(self):
# Who is friends with Anne?