コード例 #1
0
ファイル: _common.py プロジェクト: atdt/nose2
 def assertTestRunOutputMatches(self, proc, stdout=None, stderr=None):
     cmd_stdout, cmd_stderr = None, None
     try:
         cmd_stdout, cmd_stderr = self._output[proc.pid]
     except AttributeError:
         self._output = {}
     except KeyError:
         pass
     if cmd_stdout is None:
         cmd_stdout, cmd_stderr = proc.communicate()
         self._output[proc.pid] = cmd_stdout, cmd_stderr
     if stdout:
         self.assertRegexpMatches(util.safe_decode(cmd_stdout), stdout)
     if stderr:
         self.assertRegexpMatches(util.safe_decode(cmd_stderr), stderr)
コード例 #2
0
ファイル: _common.py プロジェクト: federicoferniot/behave
 def assertTestRunOutputMatches(self, proc, stdout=None, stderr=None):
     cmd_stdout, cmd_stderr = None, None
     try:
         cmd_stdout, cmd_stderr = self._output[proc.pid]
     except AttributeError:
         self._output = {}
     except KeyError:
         pass
     if cmd_stdout is None:
         cmd_stdout, cmd_stderr = proc.communicate()
         self._output[proc.pid] = cmd_stdout, cmd_stderr
     testf = self.assertRegex if hasattr(self, 'assertRegex') \
         else self.assertRegexpMatches
     if stdout:
         testf(util.safe_decode(cmd_stdout), stdout)
     if stderr:
         testf(util.safe_decode(cmd_stderr), stderr)
コード例 #3
0
ファイル: _common.py プロジェクト: hugovk/nose2
 def assertTestRunOutputMatches(self, proc, stdout=None, stderr=None):
     cmd_stdout, cmd_stderr = None, None
     try:
         cmd_stdout, cmd_stderr = self._output[proc.pid]
     except AttributeError:
         self._output = {}
     except KeyError:
         pass
     if cmd_stdout is None:
         cmd_stdout, cmd_stderr = proc.communicate()
         self._output[proc.pid] = cmd_stdout, cmd_stderr
     # Python 2.7 needs this
     # assertRegexpMatches() was renamed to assertRegex() in 3.2
     testf = self.assertRegex if hasattr(self, 'assertRegex') \
         else self.assertRegexpMatches
     if stdout:
         testf(util.safe_decode(cmd_stdout), stdout)
     if stderr:
         testf(util.safe_decode(cmd_stderr), stderr)
コード例 #4
0
 def assertTestRunOutputMatches(self, proc, stdout=None, stderr=None):
     cmd_stdout, cmd_stderr = None, None
     try:
         cmd_stdout, cmd_stderr = self._output[proc.pid]
     except AttributeError:
         self._output = {}
     except KeyError:
         pass
     if cmd_stdout is None:
         cmd_stdout, cmd_stderr = proc.communicate()
         self._output[proc.pid] = cmd_stdout, cmd_stderr
     # Python 2.7 needs this
     # assertRegexpMatches() was renamed to assertRegex() in 3.2
     testf = (self.assertRegex
              if hasattr(self, "assertRegex") else self.assertRegexpMatches)
     if stdout:
         testf(util.safe_decode(cmd_stdout), stdout)
     if stderr:
         testf(util.safe_decode(cmd_stderr), stderr)
コード例 #5
0
 def test_does_not_crash_with_mixed_unicode_and_nonascii_str(self):
     self.plugin.captureStderr = True
     test = self.case('test_mixed_unicode_and_nonascii_str')
     test(self.result)
     evt = events.OutcomeDetailEvent(self.watcher.events[0])
     self.session.hooks.outcomeDetail(evt)
     extraDetail = "".join(evt.extraDetail)
     if six.PY2:
         for string in [util.safe_decode(self.case.printed_nonascii_str), self.case.printed_unicode]:
             assert string not in extraDetail, "Output unexpectedly found in error message"
         assert "OUTPUT ERROR" in extraDetail
         assert "UnicodeDecodeError" in extraDetail
     else:
         for string in [repr(self.case.printed_nonascii_str), self.case.printed_unicode]:
             assert string in extraDetail, "Output not found in error message"
コード例 #6
0
 def _getOutcomeDetail(self, event):
     evt = events.OutcomeDetailEvent(event)
     result = self.session.hooks.outcomeDetail(evt)
     if evt.handled:
         return result
     exc_info = getattr(event, 'exc_info', None)
     test = getattr(event, 'test', None)
     if exc_info:
         detail = [util.exc_info_to_string(exc_info, test)]
     else:
         detail = []
     if evt.extraDetail:
         detail.extend(evt.extraDetail)
     try:
         return "\n".join(detail)
     except UnicodeDecodeError:
         return "\n".join(util.safe_decode(d) for d in detail)
コード例 #7
0
ファイル: result.py プロジェクト: billyjf/nose2
 def _getOutcomeDetail(self, event):
     evt = events.OutcomeDetailEvent(event)
     result = self.session.hooks.outcomeDetail(evt)
     if evt.handled:
         return result
     exc_info = getattr(event, 'exc_info', None)
     test = getattr(event, 'test', None)
     if exc_info:
         detail = [util.exc_info_to_string(exc_info, test)]
     else:
         detail = []
     if evt.extraDetail:
         detail.extend(evt.extraDetail)
     try:
         return "\n".join(detail)
     except UnicodeDecodeError:
         return "\n".join(util.safe_decode(d) for d in detail)
コード例 #8
0
        class Test(TestCase):

            printed_nonascii_str = util.safe_decode("test 日本").encode("utf-8")
            printed_unicode = six.u("hello")

            def test_out(self):
                six.print_("hello")
                raise {}["oops"]

            def test_err(self):
                six.print_("goodbye", file=sys.stderr)

            def test_mixed_unicode_and_nonascii_str(self):
                six.print_(self.printed_nonascii_str)
                six.print_(self.printed_unicode)
                six.print_(self.printed_nonascii_str, file=sys.stderr)
                six.print_(self.printed_unicode, file=sys.stderr)
                raise {}["oops"]