Beispiel #1
0
    def test_reversi_load_extra_file_no_file_error(self):
        app = Reversi()
        app.err_msg = TestErrMsg()
        with captured_stdout() as stdout:
            app._load_extra_file('./no_file')

        lines = stdout.getvalue().splitlines()
        self.assertEqual(lines[0], '指定された登録ファイルが見つかりませんでした')
Beispiel #2
0
    def test_reversi_load_extra_file_format_error(self):
        app = Reversi()
        app.err_msg = TestErrMsg()
        with captured_stdout() as stdout:
            app._load_extra_file('./not_json.json')

        lines = stdout.getvalue().splitlines()
        self.assertEqual(lines[0], 'フォーマットエラーのため登録ファイルが読み込めませんでした')
Beispiel #3
0
    def test_reversi__init(self):
        class TestWindow:
            def __init__(self):
                self.extra_file = None

            def init_screen(self):
                print('init_screen')

            def set_state(self, state):
                print(state)

        def _load_extra_file(extra_file):
            print(extra_file)

        # no extra_file
        app = Reversi()
        app.window = TestWindow()
        app._load_extra_file = _load_extra_file
        with captured_stdout() as stdout:
            app._Reversi__init()

        lines = stdout.getvalue().splitlines()
        self.assertEqual(lines[0], 'init_screen')
        self.assertEqual(lines[1], 'normal')
        with self.assertRaises(IndexError):
            print(lines[2])
        self.assertEqual(app.state, Reversi.DEMO)

        # extra_file
        app = Reversi()
        app.window = TestWindow()
        app.window.extra_file = 'extra_file'
        app._load_extra_file = _load_extra_file
        with captured_stdout() as stdout:
            app._Reversi__init()

        lines = stdout.getvalue().splitlines()
        self.assertEqual(lines[0], 'init_screen')
        self.assertEqual(lines[1], 'normal')
        self.assertEqual(lines[2], 'extra_file')
        self.assertEqual(app.window.extra_file, '')
        self.assertEqual(app.state, Reversi.DEMO)
Beispiel #4
0
    def test_reversi_load_extra_file(self):
        app = Reversi()
        app._load_extra_file('./extra_file.json')

        self.assertEqual(app.players_info['EXTERNAL'].cmd, 'cmd external')
        self.assertEqual(app.players_info['EXTERNAL'].timeouttime, 10)