1
1
"""Tests for Target class."""
2
2
3
+ from typing import Final
4
+
3
5
import pytest
4
6
5
7
from archeryutils .targets import ScoringSystem , Target
@@ -251,9 +253,7 @@ def test_min_score_invalid_face_type(self) -> None:
251
253
],
252
254
)
253
255
def test_get_face_spec (self , scoring_system , diam ) -> None :
254
- """
255
- Check that target returns correct face specifications from supported scoring systems.
256
- """
256
+ """Check that target returns face specs from supported scoring systems."""
257
257
expected_spec = {
258
258
"5_zone" : {0.244 : 9 , 0.488 : 7 , 0.732 : 5 , 0.976 : 3 , 1.22 : 1 },
259
259
"10_zone" : {
@@ -281,34 +281,25 @@ def test_get_face_spec(self, scoring_system, diam) -> None:
281
281
282
282
283
283
class TestCustomScoringTarget :
284
- """
285
- Tests for Target class with custom scoring
286
- """
284
+ """Tests for Target class with custom scoring."""
287
285
288
- _11zone_spec = {0.02 : 11 , 0.04 : 10 , 0.8 : 9 , 0.12 : 8 , 0.16 : 7 , 0.2 : 6 }
286
+ _11zone_spec : Final = {0.02 : 11 , 0.04 : 10 , 0.8 : 9 , 0.12 : 8 , 0.16 : 7 , 0.2 : 6 }
289
287
290
288
def test_constructor (self ) -> None :
291
- """
292
- Can initialise Target with a custom scoring system and spec
293
- """
294
-
289
+ """Can initialise Target with a custom scoring system and spec."""
295
290
target = Target .from_spec ({0.1 : 3 , 0.5 : 1 }, 80 , (50 , "yard" ))
296
291
assert target .distance == 50.0 * 0.9144
297
292
assert target .diameter == 0.8
298
293
assert target .scoring_system == "Custom"
299
294
assert target .get_face_spec () == {0.1 : 3 , 0.5 : 1 }
300
295
301
296
def test_face_spec_units (self ) -> None :
302
- """
303
- Check custom Target can be constructed with alternative units.
304
- """
297
+ """Check custom Target can be constructed with alternative units."""
305
298
target = Target .from_spec (({10 : 5 , 20 : 4 , 30 : 3 }, "cm" ), 50 , 30 )
306
299
assert target .get_face_spec () == {0.1 : 5 , 0.2 : 4 , 0.3 : 3 }
307
300
308
301
def test_invalid_face_spec_units (self ) -> None :
309
- """
310
- Check custom Target cannot be constructed with unsupported units.
311
- """
302
+ """Check custom Target cannot be constructed with unsupported units."""
312
303
with pytest .raises (
313
304
ValueError ,
314
305
# match=
@@ -333,23 +324,17 @@ def test_invalid_face_spec_units(self) -> None:
333
324
],
334
325
)
335
326
def test_equality (self , spec , args , result ) -> None :
336
- """
337
- Check custom Target equality comparison is supported.
338
- """
327
+ """Check custom Target equality comparison is supported."""
339
328
target = Target .from_spec ({0.2 : 2 , 0.4 : 1 }, 40 , 20 , indoor = True )
340
329
comparison = target == Target .from_spec (spec , * args )
341
330
assert comparison == result
342
331
343
332
def test_max_score (self ) -> None :
344
- """
345
- Check that Target with custom scoring system returns correct max score
346
- """
333
+ """Check that Target with custom scoring system returns correct max score."""
347
334
target = Target .from_spec (self ._11zone_spec , 40 , 18 )
348
335
assert target .max_score () == 11
349
336
350
337
def test_min_score (self ) -> None :
351
- """
352
- Check that Target with custom scoring system returns correct min score
353
- """
338
+ """Check that Target with custom scoring system returns correct min score."""
354
339
target = Target .from_spec (self ._11zone_spec , 40 , 18 )
355
340
assert target .min_score () == 6
0 commit comments