コード例 #1
0
 def test_check_engine_options__multiple_unknown_option(self):
     with self.assertRaises(ValueError) as error:
         options = dict(TEST_ENGINE_OPTIONS_DICT)
         options['unknown1'] = ''
         options['unknown2'] = ''
         settings_loader.check_engine_options(TEST_ENGINE_OPTIONS, options)
     self.assertTrue('Unknown options [\'unknown1\', \'unknown2\']' in str(error.exception))
コード例 #2
0
 def test_check_engine_options__multiple_button_option(self):
     with self.assertRaises(ValueError) as error:
         options = dict(TEST_ENGINE_OPTIONS_DICT)
         options['button1'] = None
         options['button2'] = None
         settings_loader.check_engine_options(TEST_ENGINE_OPTIONS, options)
     self.assertTrue('Cannot set button options [\'button1\', \'button2\']' in str(error.exception))
コード例 #3
0
 def test_check_engine_options__managed_option(self):
     with self.assertRaises(ValueError) as error:
         options = dict(TEST_ENGINE_OPTIONS_DICT)
         options['uci_chess960'] = True
         options['uci_variant'] = None
         options['multipv'] = 2
         options['ponder'] = True
         settings_loader.check_engine_options(TEST_ENGINE_OPTIONS, options)
     error_msg = 'Cannot set managed options [\'uci_chess960\', \'uci_variant\', \'multipv\', \'ponder\']'
     self.assertTrue(error_msg in str(error.exception))
コード例 #4
0
ファイル: opex.py プロジェクト: Eirik0/opening-explorer
def load_all_engine_options(settings: Json) -> Dict[str, engine.ConfigMapping]:
    """Loads engine options."""
    engine_options: Dict[str, engine.ConfigMapping] = {}
    for engine_setting in typing.cast(List[Json], settings['engines']):
        nickname = typing.cast(str, engine_setting['nickname'])
        path = typing.cast(str, engine_setting['path'])
        with engine.SimpleEngine.popen_uci(path) as uci_engine:
            default_options = [option for _, option in uci_engine.options.items()]
        engine_options_directory = settings['engine_options_directory']
        options_file_path = f'{engine_options_directory}\\{nickname}.uci'
        ensure_file_exists(options_file_path)
        with open(options_file_path, 'r+') as options_file:
            simple_options = settings_loader.load_engine_options_simple(options_file)
            settings_loader.check_engine_options(default_options, simple_options)
            options_file.seek(0)
            options_with_defaults = settings_loader.load_engine_options(default_options, options_file, False)
            options_file.seek(0)
            if simple_options != options_with_defaults:
                options_file.writelines(
                    settings_loader.engine_options_file_lines(default_options, options_with_defaults))
                options_file.seek(0)
            engine_options[nickname] = settings_loader.load_engine_options(default_options, options_file)
    return engine_options
コード例 #5
0
 def test_check_engine_options__combo_type__not_in_list(self):
     with self.assertRaises(ValueError) as error:
         options = dict(TEST_ENGINE_OPTIONS_DICT)
         options['combo'] = 'four'
         settings_loader.check_engine_options(TEST_ENGINE_OPTIONS, options)
     self.assertTrue('Value \'four\' for \'combo\' not in [\'one\', \'two\', \'three\']' in str(error.exception))
コード例 #6
0
 def test_check_engine_options__check_type__blank__not_boolean(self):
     with self.assertRaises(ValueError) as error:
         options = dict(TEST_ENGINE_OPTIONS_DICT)
         options['check_true'] = ''
         settings_loader.check_engine_options(TEST_ENGINE_OPTIONS, options)
     self.assertTrue('Value \'\' for \'check_true\' not a boolean' in str(error.exception))
コード例 #7
0
 def test_check_engine_options__spin_type__blank__not_integer(self):
     with self.assertRaises(ValueError) as error:
         options = dict(TEST_ENGINE_OPTIONS_DICT)
         options['spin'] = ''
         settings_loader.check_engine_options(TEST_ENGINE_OPTIONS, options)
     self.assertTrue('Value \'\' for \'spin\' not an integer' in str(error.exception))
コード例 #8
0
 def test_check_engine_options__spin_type__value_above_range(self):
     with self.assertRaises(ValueError) as error:
         options = dict(TEST_ENGINE_OPTIONS_DICT)
         options['spin'] = 101
         settings_loader.check_engine_options(TEST_ENGINE_OPTIONS, options)
     self.assertTrue('Value \'101\' for \'spin\' not in range [-100, 100]' in str(error.exception))