def test_firstNN(self): self.assertEqual(libpelita.firstNN(None, False, True), False) self.assertEqual(libpelita.firstNN(True, False, True), True) self.assertEqual(libpelita.firstNN(None, None, True), True) self.assertEqual(libpelita.firstNN(None, 2, True), 2) self.assertEqual(libpelita.firstNN(None, None, None), None) self.assertEqual(libpelita.firstNN(), None)
def test_firstNN(self): assert libpelita.firstNN(None, False, True) == False assert libpelita.firstNN(True, False, True) == True assert libpelita.firstNN(None, None, True) == True assert libpelita.firstNN(None, 2, True) == 2 assert libpelita.firstNN(None, None, None) == None assert libpelita.firstNN() == None
if ARGS.help: parser.print_help() sys.exit(0) elif ARGS.setup: setup() sys.exit(0) # Check that pelitagame can be run if not os.path.isfile(ARGS.pelitagame): sys.stderr.write(ARGS.pelitagame + " not found!\n") sys.exit(2) with open(ARGS.config) as f: config_data = yaml.load(f) config_data["viewer"] = ARGS.viewer or config_data.get("viewer", "tk") config_data["interactive"] = libpelita.firstNN(ARGS.interactive, config_data.get("interactive"), True) config_data["statefile"] = ARGS.state config_data["speak"] = libpelita.firstNN(ARGS.speak, config_data.get("speak")) config_data["speaker"] = ARGS.speaker or config_data.get("speaker") config = Config(config_data) if not ARGS.no_log: # create a directory for the dumps def escape(s): return "-" + re.sub(r"[\W]", "_", str(s)) if s else "" storage_folder = create_directory( "./store{location}{year}".format(location=escape(config.location), year=escape(config.date)) )
sys.exit(0) elif ARGS.setup: setup() sys.exit(0) # Check that pelitagame can be run if not os.path.isfile(ARGS.pelitagame): sys.stderr.write(ARGS.pelitagame+' not found!\n') sys.exit(2) with open(ARGS.config) as f: config_data = yaml.load(f) config_data['viewer'] = ARGS.viewer or config_data.get('viewer', 'tk') config_data['interactive'] = libpelita.firstNN(ARGS.interactive, config_data.get('interactive'), True) config_data['statefile'] = ARGS.state config_data['speak'] = libpelita.firstNN(ARGS.speak, config_data.get('speak')) config_data['speaker'] = ARGS.speaker or config_data.get('speaker') config = Config(config_data) if not ARGS.no_log: # create a directory for the dumps def escape(s): return "-" + re.sub(r'[\W]', '_', str(s)) if s else "" storage_folder = create_directory('./store{location}{year}'.format(location=escape(config.location), year=escape(config.date))) config.tournament_log_folder = storage_folder