Skip to content

Commit 4641166

Browse files
committed
Remove support for parallel processing on Windows.
1 parent fe617ee commit 4641166

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

axelrod/tests/integration/test_tournament.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import axelrod
3-
import tempfile
43
import filecmp
4+
import sys
55

66
from axelrod.strategy_transformers import FinalTransformer
77

@@ -34,9 +34,9 @@ def test_full_tournament(self):
3434
tournament = axelrod.Tournament(name='test', players=strategies,
3535
game=self.game, turns=2,
3636
repetitions=2)
37-
tmp_file = tempfile.NamedTemporaryFile()
37+
filename = "test_outputs/test_tournament.csv"
3838
self.assertIsNone(tournament.play(progress_bar=False,
39-
filename=tmp_file.name,
39+
filename=filename,
4040
build_results=False))
4141

4242
def test_serial_play(self):
@@ -50,6 +50,8 @@ def test_serial_play(self):
5050
actual_outcome = sorted(zip(self.player_names, scores))
5151
self.assertEqual(actual_outcome, self.expected_outcome)
5252

53+
@unittest.skipIf(sys.platform.startswith("win"),
54+
"Parallel processing not supported on Windows")
5355
def test_parallel_play(self):
5456
tournament = axelrod.Tournament(
5557
name=self.test_name,
@@ -71,10 +73,10 @@ def test_repeat_tournament_deterministic(self):
7173
players=deterministic_players,
7274
game=self.game, turns=2,
7375
repetitions=2)
74-
files.append(tempfile.NamedTemporaryFile())
75-
tournament.play(progress_bar=False, filename=files[-1].name,
76+
files.append("test_outputs/stochastic_tournament_{}.csv".format(_))
77+
tournament.play(progress_bar=False, filename=files[-1],
7678
build_results=False)
77-
self.assertTrue(filecmp.cmp(files[0].name, files[1].name))
79+
self.assertTrue(filecmp.cmp(files[0], files[1]))
7880

7981
def test_repeat_tournament_stochastic(self):
8082
"""
@@ -89,10 +91,10 @@ def test_repeat_tournament_stochastic(self):
8991
players=stochastic_players,
9092
game=self.game, turns=2,
9193
repetitions=2)
92-
files.append(tempfile.NamedTemporaryFile())
93-
tournament.play(progress_bar=False, filename=files[-1].name,
94+
files.append("test_outputs/stochastic_tournament_{}.csv".format(_))
95+
tournament.play(progress_bar=False, filename=files[-1],
9496
build_results=False)
95-
self.assertTrue(filecmp.cmp(files[0].name, files[1].name))
97+
self.assertTrue(filecmp.cmp(files[0], files[1]))
9698

9799

98100
class TestNoisyTournament(unittest.TestCase):

axelrod/tests/unit/test_tournament.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from multiprocessing import Queue, cpu_count
66
import unittest
77
import warnings
8+
import sys
89

910
from hypothesis import given, example, settings
1011
from hypothesis.strategies import integers, floats
@@ -189,6 +190,8 @@ def test_progress_bar_play(self):
189190
self.assertIsInstance(results, axelrod.ResultSet)
190191
self.assertEqual(tournament.progress_bar.total, 15)
191192

193+
@unittest.skipIf(sys.platform.startswith("win"),
194+
"Parallel processing not supported on Windows")
192195
def test_progress_bar_play_parallel(self):
193196
"""Test that tournament plays when asking for progress bar for parallel
194197
tournament"""
@@ -234,6 +237,8 @@ def test_property_serial_play(self, tournament):
234237
self.assertEqual(results.nplayers, len(tournament.players))
235238
self.assertEqual(results.players, [str(p) for p in tournament.players])
236239

240+
@unittest.skipIf(sys.platform.startswith("win"),
241+
"Parallel processing not supported on Windows")
237242
def test_parallel_play(self):
238243
# Test that we get an instance of ResultSet
239244
tournament = axelrod.Tournament(
@@ -274,6 +279,8 @@ def test_run_serial(self):
274279
calls = tournament._write_interactions.call_args_list
275280
self.assertEqual(len(calls), 15)
276281

282+
@unittest.skipIf(sys.platform.startswith("win"),
283+
"Parallel processing not supported on Windows")
277284
def test_run_parallel(self):
278285
tournament = axelrod.Tournament(
279286
name=self.test_name,
@@ -289,6 +296,8 @@ def test_run_parallel(self):
289296
calls = tournament._write_interactions.call_args_list
290297
self.assertEqual(len(calls), 15)
291298

299+
@unittest.skipIf(sys.platform.startswith("win"),
300+
"Parallel processing not supported on Windows")
292301
def test_n_workers(self):
293302
max_processes = cpu_count()
294303

@@ -309,6 +318,8 @@ def test_n_workers(self):
309318
self.assertEqual(tournament._n_workers(processes=max_processes+2),
310319
max_processes)
311320

321+
@unittest.skipIf(sys.platform.startswith("win"),
322+
"Parallel processing not supported on Windows")
312323
@unittest.skipIf(
313324
cpu_count() < 2,
314325
"not supported on single processor machines")
@@ -324,6 +335,8 @@ def test_2_workers(self):
324335
repetitions=self.test_repetitions,)
325336
self.assertEqual(tournament._n_workers(processes=2), 2)
326337

338+
@unittest.skipIf(sys.platform.startswith("win"),
339+
"Parallel processing not supported on Windows")
327340
def test_start_workers(self):
328341
workers = 2
329342
work_queue = Queue()
@@ -346,6 +359,8 @@ def test_start_workers(self):
346359
stops += 1
347360
self.assertEqual(stops, workers)
348361

362+
@unittest.skipIf(sys.platform.startswith("win"),
363+
"Parallel processing not supported on Windows")
349364
def test_worker(self):
350365
tournament = axelrod.Tournament(
351366
name=self.test_name,

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ Here is quick overview of the current capabilities of the library:
3232
* The Moran process
3333
* An ecological model
3434

35-
* Multi-processor support, caching for deterministic interactions, automatically
36-
generate figures and statistics
35+
* Multi-processor support (not currently supported on Windows), caching for
36+
deterministic interactions, automatically generate figures and statistics
3737

3838
Every strategy is categorized on a number of dimensions, including:
3939

0 commit comments

Comments
 (0)