MCPcopy
hub / github.com/django/django / test_name

Method test_name

tests/field_deconstruction/tests.py:13–30  ·  view source on GitHub ↗

Tests the outputting of the correct name if assigned one.

(self)

Source from the content-addressed store, hash-verified

11 """
12
13 def test_name(self):
14 """
15 Tests the outputting of the correct name if assigned one.
16 """
17 # First try using a "normal" field
18 field = models.CharField(max_length=65)
19 name, path, args, kwargs = field.deconstruct()
20 self.assertIsNone(name)
21 field.set_attributes_from_name("is_awesome_test")
22 name, path, args, kwargs = field.deconstruct()
23 self.assertEqual(name, "is_awesome_test")
24 # Now try with a ForeignKey
25 field = models.ForeignKey("some_fake.ModelName", models.CASCADE)
26 name, path, args, kwargs = field.deconstruct()
27 self.assertIsNone(name)
28 field.set_attributes_from_name("author")
29 name, path, args, kwargs = field.deconstruct()
30 self.assertEqual(name, "author")
31
32 def test_db_tablespace(self):
33 field = models.Field()

Callers

nothing calls this directly

Calls 2

deconstructMethod · 0.95

Tested by

no test coverage detected