Skip to content

Commit

Permalink
Skip tests with missing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Feb 21, 2015
1 parent eb779f1 commit fa76731
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import chess.pgn
import chess.uci
import collections
import unittest
import spur
import os.path
import textwrap
import time
import unittest

try:
from StringIO import StringIO
Expand Down Expand Up @@ -1119,6 +1119,7 @@ def test_scan_headers(self):

class StockfishTestCase(unittest.TestCase):

@unittest.skipUnless(os.path.isfile("/usr/games/stockfish"), "need /usr/games/stockfish")
def setUp(self):
self.engine = chess.uci.popen_engine("/usr/games/stockfish")
self.engine.uci()
Expand Down Expand Up @@ -1193,9 +1194,16 @@ def test_terminate(self):

class SpurEngineTestCase(unittest.TestCase):

def setUp(self):
try:
import spur
self.shell = spur.LocalShell()
except ImportError:
self.skipTest("need spur library")

@unittest.skipUnless(os.path.isfile("/usr/games/stockfish"), "need /usr/games/stockfish")
def test_local_shell(self):
shell = spur.LocalShell()
engine = chess.uci.spur_spawn_engine(shell, ["/usr/games/stockfish"])
engine = chess.uci.spur_spawn_engine(self.shell, ["/usr/games/stockfish"])

engine.uci()

Expand All @@ -1210,29 +1218,29 @@ def test_local_shell(self):
bestmove, pondermove = engine.go(mate=1, movetime=2000)
self.assertEqual(board.san(bestmove), "Qh4#")

@unittest.skipUnless(os.path.isfile("/usr/games/stockfish"), "need /usr/games/stockfish")
def test_terminate(self):
shell = spur.LocalShell()
engine = chess.uci.spur_spawn_engine(shell, ["/usr/games/stockfish"])
engine = chess.uci.spur_spawn_engine(self.shell, ["/usr/games/stockfish"])

engine.uci()
engine.go(infinite=True)

engine.terminate()
self.assertFalse(engine.is_alive())

@unittest.skipUnless(os.path.isfile("/usr/games/stockfish"), "need /usr/games/stockfish")
def test_kill(self):
shell = spur.LocalShell()
engine = chess.uci.spur_spawn_engine(shell, ["/usr/games/stockfish"])
engine = chess.uci.spur_spawn_engine(self.shell, ["/usr/games/stockfish"])

engine.uci()
engine.go(infinite=True)

engine.kill()
self.assertFalse(engine.is_alive())

@unittest.skipUnless(os.path.isfile("/usr/games/stockfish"), "need /usr/games/stockfish")
def test_async_terminate(self):
shell = spur.LocalShell()
engine = chess.uci.spur_spawn_engine(shell, ["/usr/games/stockfish"])
engine = chess.uci.spur_spawn_engine(self.shell, ["/usr/games/stockfish"])

command = engine.terminate(async=True)
command.wait()
Expand Down

0 comments on commit fa76731

Please sign in to comment.