@@ -11,76 +11,74 @@ def create_node(x, y):
1111
1212
1313def coords_str (node : Node ):
14- return f' ({ node .geo_node .geo_point .x } , { node .geo_node .geo_point .y } )'
14+ return f" ({ node .geo_node .geo_point .x } , { node .geo_node .geo_point .y } )"
1515
1616
1717def test_anschluss ():
1818 base_scenarios = [
1919 # Base scenarios are defined in "grids", so look at them like
2020 # looking at a layout (h=head, s=switch, l=left, r=right).
21-
22- ( # north to south
21+ ( # north to south
2322 (" h " ),
2423 (" s " ),
2524 (" " ),
2625 ("r l" ),
2726 ),
28- ( # northeast to southwest:
27+ ( # northeast to southwest:
2928 (" h" ),
3029 (" s " ),
3130 (" " ),
3231 ("rl " ),
3332 ),
34- ( # east to west:
33+ ( # east to west:
3534 ("r " ),
3635 (" sh" ),
3736 ("l " ),
3837 ),
39- ( # southeast to northwest:
38+ ( # southeast to northwest:
4039 ("lr " ),
4140 (" " ),
4241 (" s " ),
4342 (" h" ),
4443 ),
45- ( # south to north:
44+ ( # south to north:
4645 ("l r" ),
4746 (" " ),
4847 (" s " ),
4948 (" h " ),
5049 ),
51- ( # southwest to northeast:
50+ ( # southwest to northeast:
5251 (" lr" ),
5352 (" " ),
5453 (" s " ),
5554 ("h " ),
5655 ),
57- ( # west to east:
56+ ( # west to east:
5857 (" l" ),
5958 ("hs " ),
6059 (" r" ),
6160 ),
62- ( # northwest to southeast:
61+ ( # northwest to southeast:
6362 ("h " ),
6463 (" s " ),
6564 (" " ),
6665 (" rl" ),
6766 ),
68- ( # curved north to south:
67+ ( # curved north to south:
6968 ("h " ),
7069 ("s " ),
7170 (" " ),
7271 (" rl" ),
7372 ),
74- ( # curved east to west:
73+ ( # curved east to west:
7574 ("r " ),
7675 ("l " ),
7776 (" sh" ),
7877 ),
79- ( # branch east to west
78+ ( # branch east to west
8079 ("r " ),
8180 ("lsh" ),
8281 ),
83-
8482 ]
8583
8684 # base scenarios will be "moved around" by some offsets:
@@ -114,10 +112,14 @@ def test_anschluss():
114112
115113 print (
116114 "scenario:" ,
117- "\n head " , coords_str (head ),
118- "\n switch" , coords_str (switch ),
119- "\n left " , coords_str (left ),
120- "\n right " , coords_str (right )
115+ "\n head " ,
116+ coords_str (head ),
117+ "\n switch" ,
118+ coords_str (switch ),
119+ "\n left " ,
120+ coords_str (left ),
121+ "\n right " ,
122+ coords_str (right ),
121123 )
122124
123125 # connect all nodes to the switch
@@ -127,20 +129,23 @@ def test_anschluss():
127129 switch .calc_anschluss_of_all_nodes ()
128130
129131 # assert ``calc_anschluss_of_all_nodes`` did what it should
130- assert switch .connected_on_head == head , 'head node ' \
131- f'{ coords_str (switch .connected_on_head )} incorrect'
132- assert switch .connected_on_left == left , 'left node ' \
133- f'{ coords_str (switch .connected_on_left )} incorrect'
134- assert switch .connected_on_right == right , 'right node ' \
135- f'{ coords_str (switch .connected_on_right )} incorrect'
132+ assert switch .connected_on_head == head , (
133+ "head node " f"{ coords_str (switch .connected_on_head )} incorrect"
134+ )
135+ assert switch .connected_on_left == left , (
136+ "left node " f"{ coords_str (switch .connected_on_left )} incorrect"
137+ )
138+ assert switch .connected_on_right == right , (
139+ "right node " f"{ coords_str (switch .connected_on_right )} incorrect"
140+ )
136141
137142
138143def test_implausible_anschluss ():
139144 """Assert that detection of "Anschluss" (head, left, right) raises
140145 an exception on really implausible geographies."""
141- head = create_node (0 , 0 ) # layout:
142- switch = create_node (2 , 2 ) # l
143- left = create_node (1 , 3 ) # s r
146+ head = create_node (0 , 0 ) # layout:
147+ switch = create_node (2 , 2 ) # l
148+ left = create_node (1 , 3 ) # s r
144149 right = create_node (3 , 2 ) # h
145150
146151 switch .connected_nodes .extend ((head , left , right ))
0 commit comments