Skip to content

Commit fa0b519

Browse files
committed
Tests for Win Plot
1 parent a807fa5 commit fa0b519

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

axelrod/tests/unit/test_plot.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ def setUpClass(cls):
2626
cls.expected_boxplot_xticks_labels = ['Player3', 'Player1', 'Player2']
2727
cls.expected_boxplot_title = ('Mean score per stage game over 5 turns'
2828
' repeated 2 times (3 strategies)')
29-
3029
cls.expected_payoff_dataset = [
3130
[0.0, 3.2, 3.2],
3231
[4.2, 0.0, 2.0],
3332
[3.6, 1.8, 0.0]]
33+
cls.expected_winplot_dataset = ([[2, 4], [0, 2], [0, 0]],
34+
['Player1', 'Player2', 'Player3'])
35+
cls.expected_winplot_title = "Distributions of wins: 5 turns repeated 2 times (3 strategies)"
3436

3537
def test_init(self):
3638
result_set = self.test_result_set
@@ -67,6 +69,23 @@ def test_boxplot(self):
6769
else:
6870
self.skipTest('matplotlib not installed')
6971

72+
def test_winplot_dataset(self):
73+
plot = axelrod.Plot(self.test_result_set)
74+
self.assertSequenceEqual(
75+
plot._winplot_dataset,
76+
self.expected_winplot_dataset)
77+
78+
def test_winplot_title(self):
79+
plot = axelrod.Plot(self.test_result_set)
80+
self.assertEqual(plot._winplot_title, self.expected_winplot_title)
81+
82+
def test_winplot(self):
83+
if matplotlib_installed:
84+
plot = axelrod.Plot(self.test_result_set)
85+
self.assertIsInstance(plot.winplot(), matplotlib.pyplot.Figure)
86+
else:
87+
self.skipTest('matplotlib not installed')
88+
7089
def test_payoff_dataset(self):
7190
plot = axelrod.Plot(self.test_result_set)
7291
self.assertSequenceEqual(

0 commit comments

Comments
 (0)