1
+ from poem import print_hanging_indents
2
+
3
+ # part of William Shakespeare's play Hamlet
4
+ shakespeare_unformatted = """
5
+ To be, or not to be, that is the question:
6
+ Whether 'tis nobler in the mind to suffer
7
+
8
+ The slings and arrows of outrageous fortune,
9
+ Or to take Arms against a Sea of troubles,
10
+ """
11
+
12
+ shakespeare_formatted = """
13
+ To be, or not to be, that is the question:
14
+ Whether 'tis nobler in the mind to suffer
15
+ The slings and arrows of outrageous fortune,
16
+ Or to take Arms against a Sea of troubles,
17
+ """
18
+
19
+ # part of Remember, by Christina Rosetti
20
+ rosetti_unformatted = """
21
+ Remember me when I am gone away,
22
+ Gone far away into the silent land;
23
+ When you can no more hold me by the hand,
24
+
25
+ Nor I half turn to go yet turning stay.
26
+
27
+ Remember me when no more day by day
28
+ You tell me of our future that you planned:
29
+ Only remember me; you understand
30
+ """
31
+
32
+
33
+ rosetti_formatted = """
34
+ Remember me when I am gone away,
35
+ Gone far away into the silent land;
36
+ When you can no more hold me by the hand,
37
+ Nor I half turn to go yet turning stay.
38
+ Remember me when no more day by day
39
+ You tell me of our future that you planned:
40
+ Only remember me; you understand
41
+ """
42
+
43
+
44
+ def test_shakespeare_text (capfd ):
45
+ print_hanging_indents (shakespeare_unformatted )
46
+ output = capfd .readouterr ()[0 ]
47
+ assert output .strip () == shakespeare_formatted .strip ()
48
+
49
+
50
+ def test_rosetti_poem (capfd ):
51
+ print_hanging_indents (rosetti_unformatted )
52
+ output = capfd .readouterr ()[0 ]
53
+ assert output .strip () == rosetti_formatted .strip ()
0 commit comments