-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_game.py
32 lines (23 loc) · 848 Bytes
/
test_game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# import unittest
import pytest
from unittest.mock import patch, Mock
def test_players:
# mocking raw input
# https://stackoverflow.com/questions/21046717/python-mocking-raw-input-in-unittests
# def test_enigma_encipher(enigma):
# # check bad input
# with pytest.raises(ValueError):
# enigma.encipher('?')
# # check bad input 2
# with pytest.raises(TypeError):
# enigma.encipher(100)
# assert enigma.encipher("CHILL") == "QUPCN"
# assert enigma.encipher("c h i ll") == "HRKPO"
# assert enigma.encipher("") == ""
# with patching
# with patch.object(enigma, "encode_decode_letter") as edl:
# edl.return_value = "x"
# assert enigma.encipher("") == ""
# edl.assert_not_called()
# assert enigma.encipher(" h ") == "x"
# edl.assert_called_with("H")