def test_valid_font_weights(self): """ Asserting that only valid font-weights are allowable. """ all_valid_weights = range(100, 1001, 100) for weight in all_valid_weights: parser = ArgumentParser(description="test parser") buildspec = create_from_parser(parser, "", terminal_font_weight=weight) self.assertEqual(buildspec['terminal_font_weight'], weight)
def test_program_description(self): """ Should use `program_description` if supplied, otherwise fallback to the description on the `parser` """ parser = ArgumentParser(description="Parser Description") # when supplied explicitly, we assign it as the description buildspec = create_from_parser(parser, "", program_description='Custom Description') self.assertEqual(buildspec['program_description'], 'Custom Description') # when no explicit program_definition supplied, we fallback to the parser's description buildspec = create_from_parser(parser, "") self.assertEqual(buildspec['program_description'], 'Parser Description') # if no description is provided anywhere, we just set it to be an empty string. blank_parser = ArgumentParser() buildspec = create_from_parser(blank_parser, "") self.assertEqual(buildspec['program_description'], '')
def instrumentGooey(parser, **kwargs): """ Context manager used during testing for setup/tear down of the WX infrastructure during subTests. """ buildspec = create_from_parser(parser, "", **merge(defaults, kwargs)) app, gooey = application.build_app(buildspec) try: yield (app, gooey) finally: wx.CallAfter(app.ExitMainLoop) gooey.Destroy() app.Destroy()
def instrumentGooey(parser, **kwargs): """ Context manager used during testing for setup/tear down of the WX infrastructure during subTests. Weirdness warning: this uses a globally reused wx.App instance. """ from gooey.tests import app if app == None: raise Exception("App instance has not been created! This is likely due to " "you forgetting to add the magical import which makes all these " "tests work. See the module doc in gooey.tests.__init__ for guidance") buildspec = create_from_parser(parser, "", **merge(defaults, kwargs)) app, gooey = application._build_app(buildspec, app) app.SetTopWindow(gooey) try: yield (app, gooey) finally: wx.CallAfter(app.ExitMainLoop) gooey.Destroy() app.SetTopWindow(None) del gooey
def test_invalid_font_weights_throw_error(self): parser = ArgumentParser(description="test parser") with self.assertRaises(ValueError): invalid_weight = 9123 buildspec = create_from_parser(parser, "", terminal_font_weight=invalid_weight)
def test_font_weight_defaults_to_normal(self): parser = ArgumentParser(description="test parser") # no font_weight explicitly provided buildspec = create_from_parser(parser, "") self.assertEqual(buildspec['terminal_font_weight'], constants.FONTWEIGHT_NORMAL)