summaryrefslogtreecommitdiff
path: root/tests/many_to_one_null
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2018-11-23 21:24:25 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-15 20:22:56 +0200
commit94f63b926fd32d7a7b6e2591ef72aa8f040f25cc (patch)
tree427aa4855f08fa75d386118765fcb0035ea07052 /tests/many_to_one_null
parent3cf80d3fcf7446afdde16a2be515c423f720e54d (diff)
Refs #31395 -- Relied on setUpTestData() test data isolation in various tests.
Diffstat (limited to 'tests/many_to_one_null')
-rw-r--r--tests/many_to_one_null/tests.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/many_to_one_null/tests.py b/tests/many_to_one_null/tests.py
index 6ccabefe66..401e41b447 100644
--- a/tests/many_to_one_null/tests.py
+++ b/tests/many_to_one_null/tests.py
@@ -4,22 +4,23 @@ from .models import Article, Car, Driver, Reporter
class ManyToOneNullTests(TestCase):
- def setUp(self):
+ @classmethod
+ def setUpTestData(cls):
# Create a Reporter.
- self.r = Reporter(name='John Smith')
- self.r.save()
+ cls.r = Reporter(name='John Smith')
+ cls.r.save()
# Create an Article.
- self.a = Article(headline="First", reporter=self.r)
- self.a.save()
+ cls.a = Article(headline='First', reporter=cls.r)
+ cls.a.save()
# Create an Article via the Reporter object.
- self.a2 = self.r.article_set.create(headline="Second")
+ cls.a2 = cls.r.article_set.create(headline='Second')
# Create an Article with no Reporter by passing "reporter=None".
- self.a3 = Article(headline="Third", reporter=None)
- self.a3.save()
+ cls.a3 = Article(headline='Third', reporter=None)
+ cls.a3.save()
# Create another article and reporter
- self.r2 = Reporter(name='Paul Jones')
- self.r2.save()
- self.a4 = self.r2.article_set.create(headline='Fourth')
+ cls.r2 = Reporter(name='Paul Jones')
+ cls.r2.save()
+ cls.a4 = cls.r2.article_set.create(headline='Fourth')
def test_get_related(self):
self.assertEqual(self.a.reporter.id, self.r.id)