コード例 #1
0
ファイル: test_faulthandler.py プロジェクト: Ds110/mee-python
    def check_fatal_error(self,
                          code,
                          line_number,
                          name_regex,
                          filename=None,
                          all_threads=True,
                          other_regex=None):
        """
        Check that the fault handler for fatal errors is enabled and check the
        traceback from the child process output.

        Raise an error if the output doesn't match the expected format.
        """
        if all_threads:
            header = 'Current thread XXX'
        else:
            header = 'Traceback (most recent call first)'
        regex = """
^Fatal Python error: {name}

{header}:
  File "<string>", line {lineno} in <module>
""".strip()
        regex = regex.format(lineno=line_number,
                             name=name_regex,
                             header=re.escape(header))
        if other_regex:
            regex += '|' + other_regex
        with support.suppress_crash_popup():
            output, exitcode = self.get_output(code, filename)
        output = '\n'.join(output)
        self.assertRegex(output, regex)
        self.assertNotEqual(exitcode, 0)
コード例 #2
0
    def check_fatal_error(self, code, line_number, name_regex,
                          filename=None, all_threads=True, other_regex=None):
        """
        Check that the fault handler for fatal errors is enabled and check the
        traceback from the child process output.

        Raise an error if the output doesn't match the expected format.
        """
        if all_threads:
            header = 'Current thread XXX'
        else:
            header = 'Traceback (most recent call first)'
        regex = """
^Fatal Python error: {name}

{header}:
  File "<string>", line {lineno} in <module>
""".strip()
        regex = regex.format(
            lineno=line_number,
            name=name_regex,
            header=re.escape(header))
        if other_regex:
            regex += '|' + other_regex
        with support.suppress_crash_popup():
            output, exitcode = self.get_output(code, filename)
        output = '\n'.join(output)
        self.assertRegex(output, regex)
        self.assertNotEqual(exitcode, 0)
コード例 #3
0
 def test_no_FatalError_infinite_loop(self):
     with support.suppress_crash_popup():
         p = subprocess.Popen([sys.executable, "-c",
                               'import _testcapi;'
                               '_testcapi.crash_no_current_thread()'],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
     (out, err) = p.communicate()
     self.assertEqual(out, b'')
     # This used to cause an infinite loop.
     self.assertTrue(err.rstrip().startswith(
                      b'Fatal Python error:'
                      b' PyThreadState_Get: no current thread'))
コード例 #4
0
 def test_no_FatalError_infinite_loop(self):
     with support.suppress_crash_popup():
         p = subprocess.Popen([sys.executable, "-c",
                               'import _testcapi;'
                               '_testcapi.crash_no_current_thread()'],
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
     (out, err) = p.communicate()
     self.assertEqual(out, b'')
     # This used to cause an infinite loop.
     self.assertTrue(err.rstrip().startswith(
                      b'Fatal Python error:'
                      b' PyThreadState_Get: no current thread'))
コード例 #5
0
    def test_disable(self):
        code = """
import faulthandler
faulthandler.enable()
faulthandler.disable()
faulthandler._sigsegv()
""".strip()
        not_expected = "Fatal Python error"
        with support.suppress_crash_popup():
            stderr, exitcode = self.get_output(code)
        stder = "\n".join(stderr)
        self.assertTrue(not_expected not in stderr, "%r is present in %r" % (not_expected, stderr))
        self.assertNotEqual(exitcode, 0)
コード例 #6
0
ファイル: test_faulthandler.py プロジェクト: Ds110/mee-python
    def test_disable(self):
        code = """
import faulthandler
faulthandler.enable()
faulthandler.disable()
faulthandler._sigsegv()
""".strip()
        not_expected = 'Fatal Python error'
        with support.suppress_crash_popup():
            stderr, exitcode = self.get_output(code)
        stder = '\n'.join(stderr)
        self.assertTrue(not_expected not in stderr,
                        "%r is present in %r" % (not_expected, stderr))
        self.assertNotEqual(exitcode, 0)