Skip to content

Commit f676025

Browse files
committed
Fix test for classification
1 parent ae2bc51 commit f676025

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

axelrod/tests/unit/test_classification.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import unittest
55
from typing import Any, Text
6-
6+
import warnings
77
import yaml
88

99
import axelrod as axl
@@ -42,6 +42,10 @@ def __init__(self, x: Any):
4242

4343

4444
class TestClassification(unittest.TestCase):
45+
def setUp(self) -> None:
46+
# Ignore warnings about classifiers running on instances
47+
warnings.simplefilter("ignore", category=UserWarning)
48+
4549
def test_classifier_build(self):
4650
dirname = os.path.dirname(__file__)
4751
test_path = os.path.join(dirname, "../../../test_outputs/classifier_test.yaml")
@@ -82,7 +86,12 @@ def test_will_lookup_key_in_dict(self):
8286
self.assertEqual(Classifiers["memory_depth"](TitForTatWithEmptyClassifier), 1)
8387

8488
def test_will_lookup_key_for_classes_that_cant_init(self):
85-
self.assertEqual(Classifiers["memory_depth"](TitForTatWithNonTrivialInitialzer), 1)
89+
with self.assertRaises(Exception) as exptn:
90+
Classifiers["memory_depth"](TitForTatWithNonTrivialInitialzer)
91+
self.assertEqual(
92+
str(exptn.exception),
93+
"Passed player class doesn't have a trivial initializer.",
94+
)
8695

8796
def test_known_classifiers(self):
8897
# A set of dimensions that are known to have been fully applied

0 commit comments

Comments
 (0)