Skip to content

Commit 740ba60

Browse files
authored
Merge pull request #1120 from Axelrod-Python/clean-match-attribute-length-in-tests
Change unknown match lengths in tests.
2 parents e021ef7 + f079b4b commit 740ba60

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

axelrod/tests/strategies/test_titfortat.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_strategy(self):
4545
# This behaviour is independent of knowledge of the Match length
4646
actions = [(C, C), (C, D), (D, C), (C, D), (D, C)]
4747
self.versus_test(axelrod.Alternator(), expected_actions=actions,
48-
match_attributes={"length": -1})
48+
match_attributes={"length": float("inf")})
4949

5050
# We can also test against random strategies
5151
actions = [(C, D), (D, D), (D, C), (C, C), (C, D)]
@@ -576,7 +576,7 @@ def test_strategy(self):
576576

577577
actions = [(C, C), (C, D), (D, C), (C, D), (D, C), (C, D)]
578578
self.versus_test(axelrod.Alternator(), expected_actions=actions,
579-
match_attributes={"length": -1})
579+
match_attributes={"length": float("inf")})
580580

581581
actions = [(C, C), (C, D), (D, C), (C, D), (D, C), (D, D)]
582582
self.versus_test(axelrod.Alternator(), expected_actions=actions)
@@ -610,7 +610,7 @@ def test_strategy(self):
610610
actions = [(C, C), (C, C), (C, C), (C, C)]
611611
self.versus_test(axelrod.Cooperator(), expected_actions=actions,
612612
attrs={"is_defector": False},
613-
match_attributes={"length": -1})
613+
match_attributes={"length": float("inf")})
614614

615615
# Plays TfT and defects in last round
616616
actions = [(C, C), (C, D), (D, C), (C, D), (D, C), (D, D)]
@@ -620,7 +620,7 @@ def test_strategy(self):
620620
actions = [(C, C), (C, D), (D, C), (C, D), (D, C), (C, D)]
621621
self.versus_test(axelrod.Alternator(), expected_actions=actions,
622622
attrs={"is_defector": False},
623-
match_attributes={"length": -1})
623+
match_attributes={"length": float("inf")})
624624

625625
# Becomes defector after 5 defections
626626
opponent = axelrod.MockPlayer(actions=[D, C, D, D, D, D, C, C])
@@ -660,7 +660,7 @@ def test_strategy(self):
660660
self.versus_test(axelrod.Defector(), expected_actions=actions, init_kwargs=init_kwargs)
661661
actions = [(C, C), (C, D), (D, C), (C, D), (D, C)]
662662
self.versus_test(axelrod.Alternator(), expected_actions=actions,
663-
match_attributes={"length": -1}, init_kwargs=init_kwargs)
663+
match_attributes={"length": float("inf")}, init_kwargs=init_kwargs)
664664
actions = [(C, D), (D, D), (D, C), (C, C), (C, D)]
665665
self.versus_test(axelrod.Random(), expected_actions=actions,
666666
seed=0, init_kwargs=init_kwargs)
@@ -744,7 +744,7 @@ def test_strategy(self):
744744
actions = [(C, C), (C, C), (C, C), (C, C)]
745745
self.versus_test(axelrod.Cooperator(), expected_actions=actions,
746746
attrs={"is_defector": False},
747-
match_attributes={"length": -1}, seed=2)
747+
match_attributes={"length": float("inf")}, seed=2)
748748

749749
actions = [(C, D), (D, D), (D, D), (D, D)]
750750
self.versus_test(axelrod.Defector(), expected_actions=actions,
@@ -753,7 +753,7 @@ def test_strategy(self):
753753
actions = [(C, D), (D, D), (D, D), (D, D)]
754754
self.versus_test(axelrod.Defector(), expected_actions=actions,
755755
attrs={"is_defector": False},
756-
match_attributes={"length": -1}, seed=2)
756+
match_attributes={"length": float("inf")}, seed=2)
757757

758758
# Chance of becoming a defector is 50% after (D, C) occurs.
759759
actions = [(C, C), (C, D), (D, C), (C, D), (D, C)]
@@ -767,4 +767,4 @@ def test_strategy(self):
767767
actions = [(C, C), (C, D), (D, C), (C, D), (D, C), (D, D), (D, C)]
768768
self.versus_test(axelrod.Alternator(), expected_actions=actions,
769769
attrs={"is_defector": True},
770-
match_attributes={"length": -1}, seed=1)
770+
match_attributes={"length": float("inf")}, seed=1)

docs/tutorials/contributing/strategy/writing_test_for_the_new_strategy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ assumes that players do not know the length of the match::
4848

4949
actions = [(C, C), (C, D), (D, C), (C, D)]
5050
self.versus_test(axelrod.Alternator(), expected_actions=actions,
51-
match_attributes={"length": -1})
51+
match_attributes={"length": float("inf")})
5252

5353
The function :code:`versus_test` also accepts a dictionary parameter of
5454
keyword arguments that dictate how the player is initiated. For example this
@@ -100,7 +100,7 @@ As an example, the tests for Tit-For-Tat are as follows::
100100
# This behaviour is independent of knowledge of the Match length
101101
actions = [(C, C), (C, D), (D, C), (C, D)]
102102
self.versus_test(axelrod.Alternator(), expected_actions=actions,
103-
match_attributes={"length": -1})
103+
match_attributes={"length": float("inf")})
104104

105105
# We can also test against random strategies
106106
actions = [(C, D), (D, D), (D, C), (C, C)]

0 commit comments

Comments
 (0)