def test___deabbreviate__(self): parser = ps.Parser('Bre', self.game) self.assertEqual(parser.string, 'brest') parser = ps.Parser('-', self.game) self.assertEqual(parser.string, 'move') parser = ps.Parser('A', self.game) self.assertEqual(parser.string, 'army')
def test_parse_Diplomacy_Hold(self): parser = ps.Parser('A Par H', self.game) order = parser.new() self.assertEqual(str(order), 'French Army in Paris holds [unresolved].') with self.assertRaises(OrderInputError): parser = ps.Parser('A Bur H', self.game) parser.new()
def test_parse_Diplomacy_Convoy(self): with self.assertRaises(OrderInputError): parser = ps.Parser('F Bre C A Par - Pic', self.game) order = parser.new() self.game.order(['F Bre - ENG', 'A Par - Bre']) self.game.adjudicate() parser = ps.Parser('F ENG C A Bre - Wal', self.game) order = parser.new() self.assertEqual( str(order), 'French Fleet in English Channel convoys Brest ' 'to Wales [unresolved].')
def test_parse_Retreat(self): self.game.order(['A War - Gal', 'A Mun - Bur']) self.game.adjudicate() self.game.order([ 'A Par - Bur', 'A Mar S move Bur from Par', 'A Bud - Gal', 'A Vie S A Bud - Gal' ]) self.game.adjudicate() parser = ps.Parser('A Bur - Bel', self.game) parser.new() self.assertEqual(str(self.game.orders.orders[0]), 'The Army in Burgundy retreats to Belgium.') parser = ps.Parser('A Gal disbands', self.game) parser.new() self.assertEqual(str(self.game.orders.orders[1]), 'The Army in Galicia disbands.')
def test_parse_Diplomacy_SupportHold(self): parser = ps.Parser('A Par S F Bre H', self.game) order = parser.new() self.assertEqual( str(order), 'French Army in Paris supports the Fleet in Brest holds [unresolved].' )
def test_parse_Builds(self): self.game.delete_unit('Paris') self.game.adjudicate() self.game.adjudicate() parser = ps.Parser('France Build 1 A Par', self.game) parser.new() self.assertEqual(str(self.game.orders.orders[0]), 'French build no. 1 is Army in Paris.')
def run(fn, text): # Generate tokens lex = lexer.Lexer(fn, text) tokens, error = lex.make_tokens() if error: return None, error # Generate AST pars = parser.Parser(tokens) ast = pars.parse() if ast.error: return None, ast.error inter = Interpreter() context = Context('<program>') context.symbol_table = global_symbol_table result = inter.visit(ast.node, context) return result.value, result.error
def pytest_generate_tests(metafunc): print "pytest_generate_tests()" # load up the settings config.setup_configs(metafunc.config.option.path) browser_list = browsers if pre.config['execution'] == 'local': browser_list = [{ 'browserName': pre.config['browser'], 'platform': "%s %s" % (system(), release()) }] parse = parser.Parser(metafunc.config.option.path) test_cases = parse.get_datadict() tests = parser.proliferate(browser_list, test_cases) if 'driver' in metafunc.fixturenames: metafunc.parametrize('data', tests, ids=[value['TestName'] for value in tests], scope='function')
def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) self.parent = ttk.Frame(self) # GUI constants self.WIDTH, self.HEIGHT = 700, 600 self.APP_ICO = "icon/favicon.ico" self.APP_TITLE = "Semio" self.TITLE = "Semio v1.0" self.COPYRIGHT = "Copyright (c) Benjamin Shanahan 2016" self.HELP_WEBPAGE = "http://www.bshanahan.info/semio" self.DESCRIPTION = "Semio is a objective semiology diagnostic tool, intended for usage as a conflict mediator among surgeons during discussions concerning seizure-onset-zone.\n\nSemio has a sizeable database of semiology information pulled from current and past literature. The database can be appended at any time to reflect new developments in the field.\n\nThe user selects all symptoms exhibited by a patient, choosing also the symptom's side of onset. These selected symptoms are then used to calculate the probability of seizure onset for different locations across the brain.\n\nOnce the user has selected the patient's symptoms and chosen to render the probabilities, a 3D representation of the brain can be rendered with the probabilities overlayed." # update GUI self.minsize(self.WIDTH, self.HEIGHT) self.title(self.APP_TITLE) self.iconbitmap(os.path.abspath(self.APP_ICO)) # Semio constants self.EXPORT_EXTENSION = "*.3d" self.QUICK_EXPORT_FILENAME = "quick_export" self.EXPORT_FILETYPES = [("3D file", self.EXPORT_EXTENSION)] self.EXPORT_INITIALDIR = "export/" self.SAVE_EXTENSION = "*.semio" self.SAVE_FILETYPES = [("Symptom file", self.SAVE_EXTENSION)] self.SAVE_INITIALDIR = "saved/" self.JSON_FILEPATH = "data/data.json" self.MAX_APP_PATH = "max/Semiology.exe" # location of 3D rendering program # check if export and save directories exist, and if not, create them if not os.path.exists(self.EXPORT_INITIALDIR): os.makedirs(self.EXPORT_INITIALDIR) if not os.path.exists(self.SAVE_INITIALDIR): os.makedirs(self.SAVE_INITIALDIR) # Semio variables self.handedness = g.Constants.RIGHT self.dominant_hemisphere = g.Constants.LEFT self.regionlist = region.RegionList() # load and parse JSON file containing symptom information self.p = parser.Parser() self.p.load(self.JSON_FILEPATH) self.p.parse() # symptom display in GUI self.symptom_info = self.p.get_symptom_display_info() self.symptom_checkbutton_states = { str(i): False for i in range(len(self.symptom_info)) } self.symptom_onset_sides = { str(i): None for i in range(len(self.symptom_info)) } self.frames = {MainFrame: MainFrame(self.parent, self)} self.frames[MainFrame].pack() self.parent.pack( fill=tk.BOTH, expand=True) # pack this last so frame order is correct # add keyboard shortcut bindings self.add_bindings() # get access to things located within frame children self.symptomframe = self.frames[MainFrame].frames[SymptomFrame] self.configframe = self.frames[MainFrame].frames[ConfigFrame] self.footerframe = self.frames[MainFrame].frames[FooterFrame] self.status = self.footerframe.status
def test_parse_Diplomacy_SupportMove(self): parser = ps.Parser('A Vie S A Bud - Tri', self.game) order = parser.new() self.assertEqual( str(order), 'Austrian Army in Vienna supports the move Budapest ' 'to Trieste [unresolved].')
def test_parse_Diplomacy_Move_fleet_convoyed(self): with self.assertRaises(OrderInputError): parser = ps.Parser('F Ank - Sev via C', self.game) order = parser.new()
def test_parse_Diplomacy_Move_convoyed(self): parser = ps.Parser('A Con - Gre via C', self.game) order = parser.new() self.assertEqual(str(order), ('Turkish Army in Constantinople move via convoy to ' 'Greece [unresolved].'))
def test_parse_Diplomacy_Move(self): parser = ps.Parser('A Par - Bur', self.game) order = parser.new() self.assertEqual( str(order), 'French Army in Paris move to Burgundy [unresolved].')
def test_Decorator_load_orders(self): with self.assertRaises(OrderInputError): parser = ps.Parser('- S Convoy', self.game) parser.new() self.assertIsNotNone(parser.orders)
def test_old(self): parser = ps.Parser('A Par - Bur', self.game) self.assertEqual(str(parser.old()), 'French Army in Paris holds [unresolved].')