def test_infinite_loop_by_width():
    code = """\
n = 0
while True:
    n += 1
"""
    expected_report = """\
n = 0
      |       |
n = 1 | n = 2 | RuntimeError: live coding message limit exceeded"""
    tracer = TraceRunner()
    tracer.max_width = 20

    report = tracer.trace_code(code)

    assert report == expected_report
Beispiel #2
0
    def test_infinite_loop_by_width(self):
        # SETUP
        code = """\
n = 0
while True:
    n += 1
"""
        expected_report = """\
n = 0
      |       |
n = 1 | n = 2 | RuntimeError: live coding message limit exceeded """
        tracer = TraceRunner()
        tracer.max_width = 20

        # EXEC
        report = tracer.trace_code(code)

        # VERIFY
        self.assertReportEqual(expected_report, report)
Beispiel #3
0
    def test_infinite_recursion_by_width(self):
        # SETUP
        code = """\
def foo(n):
    foo(n+1)

foo(0)
"""
        expected_report = """\
n = 0                                            | n = 1                                            |
RuntimeError: live coding message limit exceeded | RuntimeError: live coding message limit exceeded |

RuntimeError: live coding message limit exceeded
"""
        tracer = TraceRunner()
        tracer.max_width = 13

        # EXEC
        report = tracer.trace_code(code)

        # VERIFY
        self.assertReportEqual(expected_report, report)