Skip to content

Commit 2d7ca3e

Browse files
committed
fix a migration back in post + db chap and feed thru. carrying on
1 parent 71acb3c commit 2d7ca3e

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

chapter_working_incrementally.asciidoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,14 +1328,15 @@ Migrations for 'lists':
13281328
Let's see what that gives us:
13291329

13301330
----
1331-
AssertionError: 'List object' != <List: List object>
1331+
AssertionError: 'List object (1)' != <List: List object (1)>
13321332
----
13331333

13341334

1335-
We're not quite there. Look closely at each side of the `!=`. Django has only
1336-
saved the string representation of the `List` object. To save the relationship
1337-
to the object itself, we tell Django about the relationship between the two
1338-
classes using a `ForeignKey`:
1335+
We're not quite there. Look closely at each side of the `!=`.
1336+
Do you see the quotes `'`?
1337+
Django has only saved the string representation of the `List` object.
1338+
To save the relationship to the object itself,
1339+
we tell Django about the relationship between the two classes using a `ForeignKey`:
13391340

13401341
[role="sourcecode"]
13411342
.lists/models.py
@@ -1390,13 +1391,13 @@ Back in our tests, now what happens?
13901391
----
13911392
$ pass:quotes[*python manage.py test lists*]
13921393
[...]
1393-
ERROR: test_displays_all_items (lists.tests.ListViewTest)
1394+
ERROR: test_displays_all_items
13941395
django.db.utils.IntegrityError: NOT NULL constraint failed: lists_item.list_id
13951396
[...]
1396-
ERROR: test_redirects_after_POST (lists.tests.NewListTest)
1397+
ERROR: test_redirects_after_POST
13971398
django.db.utils.IntegrityError: NOT NULL constraint failed: lists_item.list_id
13981399
[...]
1399-
ERROR: test_can_save_a_POST_request (lists.tests.NewListTest)
1400+
ERROR: test_can_save_a_POST_request
14001401
django.db.utils.IntegrityError: NOT NULL constraint failed: lists_item.list_id
14011402
14021403
Ran 6 tests in 0.021s

tests/test_chapter_working_incrementally.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,44 @@
77
Command,
88
)
99

10+
1011
class Chapter7Test(ChapterTest):
11-
chapter_name = 'chapter_working_incrementally'
12-
previous_chapter = 'chapter_explicit_waits_1'
12+
chapter_name = "chapter_working_incrementally"
13+
previous_chapter = "chapter_explicit_waits_1"
1314

1415
def test_listings_and_commands_and_output(self):
1516
self.parse_listings()
1617

1718
# sanity checks
18-
self.assertEqual(self.listings[0].type, 'code listing currentcontents')
19-
self.assertEqual(self.listings[1].type, 'output')
19+
self.assertEqual(self.listings[0].type, "code listing currentcontents")
20+
self.assertEqual(self.listings[1].type, "output")
2021

2122
# skips
22-
self.skip_with_check(40, 'should show 4 changed files') # git
23-
self.skip_with_check(45, 'add a message summarising') # git
24-
self.skip_with_check(63, '5 changed files') # git
25-
self.skip_with_check(65, 'forms x2') # git
26-
self.skip_with_check(92, '3 changed files') # git
23+
self.skip_with_check(40, "should show 4 changed files") # git
24+
self.skip_with_check(45, "add a message summarising") # git
25+
self.skip_with_check(63, "5 changed files") # git
26+
self.skip_with_check(65, "forms x2") # git
27+
self.skip_with_check(92, "3 changed files") # git
2728
touch_pos = 33
2829
touch = self.listings[touch_pos]
29-
assert 'touch' in touch
30+
assert "touch" in touch
3031

3132
# other prep
3233
self.start_with_checkout()
33-
self.run_command(Command('python3 manage.py migrate --noinput'))
34+
self.run_command(Command("python3 manage.py migrate --noinput"))
3435

3536
# hack fast-forward
3637
skip = False
3738
if skip:
3839
self.pos = 106
39-
self.sourcetree.run_command('git checkout {}'.format(
40-
self.sourcetree.get_commit_spec('ch07l036-1')
41-
))
40+
self.sourcetree.run_command(
41+
"git checkout {}".format(self.sourcetree.get_commit_spec("ch07l036-1"))
42+
)
4243

4344
while self.pos < touch_pos:
4445
print(self.pos)
4546
self.recognise_listing_and_process_it()
4647

47-
4848
# special-case: we have a touch followed by some output.
4949
# just do this one manually
5050
if self.pos < touch_pos + 1:
@@ -61,5 +61,5 @@ def test_listings_and_commands_and_output(self):
6161
self.check_final_diff(ignore=["moves", "Generated by Django 1.11"])
6262

6363

64-
if __name__ == '__main__':
64+
if __name__ == "__main__":
6565
unittest.main()

0 commit comments

Comments
 (0)