@@ -63,6 +63,9 @@ def test_cannot_add_empty_list_items(self):
63
63
----
64
64
====
65
65
66
+ // DAVID: I think we should spell out that you want us to add this to the test file. Also,
67
+ // where? As a method of NewVisitorTestCase?
68
+
66
69
That's all very well, but before we go any further--our
67
70
functional tests file is beginning to get a little crowded.
68
71
Let's split it out into several files, in which each has a single test method.
@@ -80,6 +83,8 @@ how to get there step by step.
80
83
NOTE: We're back to local development now.
81
84
Double check that the `TEST_SERVER` environment variable is unset in your terminal.
82
85
86
+ // DAVID: might be nice to remind people how they check this?
87
+
83
88
((("unittest module", "skip test decorator")))
84
89
((("refactoring")))
85
90
((("decorators", "skip test decorator")))
@@ -99,6 +104,7 @@ from unittest import skip
99
104
def test_cannot_add_empty_list_items(self):
100
105
----
101
106
====
107
+ // DAVID: The indentation here looks weird - maybe better to include the class declaration too?
102
108
103
109
This tells the test runner to ignore this test.
104
110
You can see it works--if we rerun the tests,
@@ -172,6 +178,10 @@ https://www.oreilly.com/library/view/tidy-first/9781098151232/[Tidy First?]
172
178
((("test files", "splitting FTs into many")))
173
179
We start putting each test into its own class, still in the same file:
174
180
181
+ // DAVID: I would say this is too big a refactor all in one go.
182
+ // A nicer way to do this would be to break out the base class first as one refactor, moving it into another file.
183
+ // Then when we copy the files we could rename each class and delete the irrelevant methods.
184
+
175
185
[role="sourcecode"]
176
186
.src/functional_tests/tests.py (ch11l002)
177
187
====
@@ -205,6 +215,8 @@ class ItemValidationTest(FunctionalTest):
205
215
----
206
216
====
207
217
218
+ // DAVID: I also have check_for_row_in_list_table as a method - maybe I should've removed it?
219
+
208
220
At this point we can rerun the FTs and see they all still work:
209
221
210
222
----
@@ -384,6 +396,7 @@ when we're only interested in a single one.
384
396
Although we need to remember to run all of them now and again, to check for regressions.
385
397
Later in the book we'll set up a Continuous Integration (CI) server to run all the tests automatically,
386
398
for example every time we push to master.
399
+ // DAVID: "master" -> "our main branch"
387
400
For now, a good prompt for running all the tests is "just before you do a commit",
388
401
so let's get into that habit now:
389
402
@@ -463,6 +476,8 @@ might decide that building a specific helper method is overkill at this stage,
463
476
but it might be nice to have some generic way of saying, in our tests, "wait
464
477
until this assertion passes". Something like this:
465
478
479
+ // DAVID: might be worth reminding the reader about that helper method, e.g. what it's called.
480
+
466
481
[role="sourcecode"]
467
482
.src/functional_tests/test_list_item_validation.py (ch11l009)
468
483
====
@@ -512,6 +527,8 @@ and we'll adapt it slightly:
512
527
----
513
528
====
514
529
530
+ // DAVID: I have `raise e` from that other method, not `raise`.
531
+
515
532
<1> We make a copy of the method, but we name it `wait_for`,
516
533
and we change its argument. It is expecting to be passed a function.
517
534
@@ -595,6 +612,9 @@ and that can be executed later, and multiple times:
595
612
596
613
Let's see our funky `wait_for` helper in action:
597
614
615
+ // DAVID: Might be worth explicitly telling the reader to add that code earlier - I hadn't yet,
616
+ // so I have to go back and find the right snippet.
617
+
598
618
[subs="macros,verbatim"]
599
619
----
600
620
$ pass:quotes[*python src/manage.py test functional_tests.test_list_item_validation*]
@@ -862,6 +882,8 @@ Use a tests folder::
862
882
* You probably want a separate test file for each tested source code
863
883
file. For Django, that's typically 'test_models.py', 'test_views.py', and
864
884
'test_forms.py'.
885
+ // DAVID: worth mentioning that mirroring test files to real files can pave the way for automatically running tests
886
+ // relevant to your changes.
865
887
* Have at least a placeholder test for 'every' function and class.
866
888
((("test files", "organizing and refactoring")))
867
889
0 commit comments