def execute_test(site, test): import twill.commands as commands SITE = Site.objects.get_current() now = datetime.datetime.now() print "trying %s on %s" % (test, site) twill_script = test.render(site) content = '' old_io = sys.stdout old_err = sys.stderr new_io = StringIO.StringIO() #sys.stdout = new_io commands.ERR = new_io try: execute_string(twill_script) succeeded = True content = new_io.getvalue().strip() except Exception, e: succeeded = False content = new_io.getvalue().strip() + "\n\nException:\n\n" + str(e) message = render_to_string('kong/failed_email.txt', {'site': site, 'test': test, 'error': content, 'url': SITE.domain}) if hasattr(settings, 'KONG_MAIL_MANAGERS'): mail_managers('Kong Test Failed: %s (%s)' % (test, site), message) if hasattr(settings, 'KONG_MAIL_ADMINS'): mail_admins('Kong Test Failed: %s (%s)' % (test, site), message)
def run_test(*args): try: execute_string(func.__doc__, no_reset = False) except TwillAssertionError, err: if args and hasattr(args[0], 'fail'): args[0].fail(str(err)) else: raise
def run_test(*args): try: execute_string(func.__doc__, no_reset=False) except TwillAssertionError, err: if args and hasattr(args[0], 'fail'): args[0].fail(str(err)) else: raise
def execute_test(site, test): import twill.commands as commands twill_script = test.render(site) content = '' old_err = sys.stderr new_err = StringIO.StringIO() commands.ERR = new_err now = datetime.datetime.now() try: execute_string(twill_script) succeeded = True content = new_err.getvalue().strip() except Exception, e: succeeded = False content = new_err.getvalue().strip() + "\n\nException:\n\n" + str(e)
def execute_test(site, test): now = datetime.datetime.now() print "trying %s on %s" % (test, site) twill_script = test.render(site) content = '' try: execute_string(twill_script) succeeded = True except Exception, e: succeeded = False content = str(e) message = render_to_string('kong/failed_email.txt', {'site': site, 'test': test, 'error': content, 'url': SITE.domain}) if hasattr(settings, 'KONG_MAIL_MANAGERS'): mail_managers('Kong Test Failed', message) if hasattr(settings, 'KONG_MAIL_ADMINS'): mail_admins('Kong Test Failed', message)
def execute_test(site, test): import twill.commands as commands #Avoid circular import from kong.models import TestResult twill_script = test.render(site) content = '' old_err = sys.stderr new_err = StringIO.StringIO() commands.ERR = new_err now = datetime.datetime.now() try: if getattr(settings, 'KONG_RESET_BROWSER', False): execute_string(twill_script, no_reset = False) else: execute_string(twill_script) succeeded = True content = new_err.getvalue().strip() except Exception, e: succeeded = False content = new_err.getvalue().strip() + "\n\nException:\n\n" + str(e)
def execute_test(site, test): import twill.commands as commands #Avoid circular import from kong.models import TestResult twill_script = test.render(site) content = '' old_err = sys.stderr new_err = StringIO.StringIO() commands.ERR = new_err now = datetime.datetime.now() try: if getattr(settings, 'KONG_RESET_BROWSER', False): execute_string(twill_script, no_reset=False) else: execute_string(twill_script) succeeded = True content = new_err.getvalue().strip() except Exception, e: succeeded = False content = new_err.getvalue().strip() + "\n\nException:\n\n" + str(e)