Skip to content

Commit

Permalink
format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Aug 29, 2024
1 parent 97b135f commit b85162d
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions tests/stockfish/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from subprocess import Popen
import os


def send_command(process: Popen, command):
process.stdin.write(command + "\n")
process.stdin.flush()
Expand All @@ -14,12 +15,13 @@ def send_command(process: Popen, command):
line = process.stdout.readline()
lines.append(line)
print(line)
if line in ('', '\n'):
if line in ("", "\n"):
break
if any(x in line for x in ('bestmove', 'isready', 'readyok', 'uciok')):
if any(x in line for x in ("bestmove", "isready", "readyok", "uciok")):
break
return lines


class TestStockfish:

def test_sf_process(self):
Expand All @@ -35,18 +37,33 @@ def test_sf_process(self):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
text=True,
)

send_command(process, "uci")
send_command(process, "isready")
send_command(process, "position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
send_command(process, "position fen rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1")
send_command(process, "position fen rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2")
send_command(
process,
"position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
)
send_command(
process,
"position fen rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1",
)
send_command(
process,
"position fen rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2",
)
wtime_lines = send_command(process, "go wtime 1000")
btime_lines = send_command(process, "go btime 1000")
send_command(process, "quit")
assert any(x.startswith(f'bestmove {move}') for move in ('d2d4', 'b1c3') for x in wtime_lines)
assert any(x.startswith(f'bestmove {move}') for move in ('d2d4', 'b1c3') for x in btime_lines)


assert any(
x.startswith(f"bestmove {move}")
for move in ("d2d4", "b1c3")
for x in wtime_lines
)
assert any(
x.startswith(f"bestmove {move}")
for move in ("d2d4", "b1c3")
for x in btime_lines
)

0 comments on commit b85162d

Please sign in to comment.