def test_executeTask_unicode(self): rep = reporter.ConsoleReporter(StringIO(), {}) def do_nothing():pass task_name = "中文 with_action" t1 = Task(task_name, [(do_nothing,)]) rep.execute_task(t1) assert ". 中文 with_action\n" == rep.outstream.getvalue()
def test_executeHidden(self): rep = reporter.ConsoleReporter(io.StringIO(), {}) def do_nothing(): pass t1 = Task("_hidden", [(do_nothing, )]) rep.execute_task(t1) assert "" == rep.outstream.getvalue()
def test_executeTask(self): rep = reporter.ConsoleReporter(io.StringIO(), {}) def do_nothing(): pass t1 = Task("with_action", [(do_nothing, )]) rep.execute_task(t1) assert ". with_action\n" == rep.outstream.getvalue()
def test_complete_run_verbosity2(self): rep = reporter.ConsoleReporter(StringIO(), {}) catched = CatchedException("catched exception there", Exception("foo")) rep.add_failure(Task("t_name", None, verbosity=2), catched) # assign new StringIO so output is only from complete_run() rep.outstream = StringIO() rep.complete_run() got = rep.outstream.getvalue() assert "<stdout>" not in got assert "<stderr>" not in got
def test_complete_run_verbosity2_redisplay(self): rep = reporter.ConsoleReporter(StringIO(), {'failure_verbosity': 2}) catched = CatchedException("catched exception there", Exception("foo")) task = Task("t_name", None, verbosity=2) task.executed = True rep.add_failure(task, catched) # assign new StringIO so output is only from complete_run() rep.outstream = StringIO() rep.complete_run() got = rep.outstream.getvalue() assert "<stdout>" in got assert "<stderr>" in got
def test_runtime_error(self): msg = "runtime error" rep = reporter.ConsoleReporter(StringIO(), {}) assert [] == rep.runtime_errors # no imediate output rep.runtime_error(msg) assert 1 == len(rep.runtime_errors) assert msg == rep.runtime_errors[0] assert "" in rep.outstream.getvalue() # runtime errors abort execution rep.complete_run() got = rep.outstream.getvalue() assert msg in got assert "Execution aborted" in got
def test_addFailure(self): rep = reporter.ConsoleReporter(StringIO(), {}) try: raise Exception("original 中文 exception message here") except Exception as e: catched = CatchedException("catched exception there", e) rep.add_failure(Task("t_name", None), catched) rep.complete_run() got = rep.outstream.getvalue() # description assert "Exception: original 中文 exception message here" in got, got # traceback assert """raise Exception("original 中文 exception message here")""" in got # catched message assert "catched exception there" in got
def test_startTask(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.get_status(Task("t_name", None)) # no output on start task assert "" in rep.outstream.getvalue()
def test_teardownTask(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.teardown_task(Task("t_name", None)) # no output on teardown task assert "" in rep.outstream.getvalue()
def test_addSuccess(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.add_success(Task("t_name", None)) # no output on success task assert "" in rep.outstream.getvalue()
def test_skipIgnore(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.skip_ignore(Task("t_name", None)) assert "!! " in rep.outstream.getvalue() assert "t_name" in rep.outstream.getvalue()
def test_cleanupError(self, capsys): rep = reporter.ConsoleReporter(StringIO(), {}) exception = CatchedException("I got you") rep.cleanup_error(exception) err = capsys.readouterr()[1] assert "I got you" in err
def test_skipUptodate(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.skip_uptodate(Task("t_name", None)) assert "-- " in rep.outstream.getvalue() assert "t_name" in rep.outstream.getvalue()
def test_executeGroupTask(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.execute_task(Task("t_name", None)) assert "" == rep.outstream.getvalue()
def test_addFailure(self): rep = reporter.ConsoleReporter(io.StringIO(), {}) try: raise Exception("original exception message here") except Exception, e: catched = CatchedException("catched exception there", e)
def test_skipUptodate_hidden(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.skip_uptodate(Task("_name", None)) assert "" == rep.outstream.getvalue()
def test_initialize(self): rep = reporter.ConsoleReporter(StringIO(), {}) rep.initialize([Task("t_name", None)]) # no output on initialize assert "" in rep.outstream.getvalue()