File tree Expand file tree Collapse file tree 1 file changed +23
-22
lines changed
Lib/test/test_profiling/test_sampling_profiler Expand file tree Collapse file tree 1 file changed +23
-22
lines changed Original file line number Diff line number Diff line change 11"""Tests for blocking mode sampling profiler."""
22
33import io
4+ import textwrap
45import unittest
56from unittest import mock
67
@@ -41,28 +42,28 @@ def setUpClass(cls):
4142 # When consume_generator is on the arithmetic lines (temp1, temp2, etc.),
4243 # fibonacci_generator should NOT be in the stack at all.
4344 # Line numbers are important here - see ARITHMETIC_LINES below.
44- cls .generator_script = '''
45- def fibonacci_generator(n):
46- a, b = 0, 1
47- for _ in range(n):
48- yield a
49- a, b = b, a + b
50-
51- def consume_generator():
52- gen = fibonacci_generator(10000)
53- for value in gen:
54- temp1 = value + 1
55- temp2 = value * 2
56- temp3 = value - 1
57- result = temp1 + temp2 + temp3
58-
59- def main():
60- while True:
61- consume_generator()
62-
63- _test_sock.sendall(b"working")
64- main()
65- '''
45+ cls .generator_script = textwrap . dedent ( '''
46+ def fibonacci_generator(n):
47+ a, b = 0, 1
48+ for _ in range(n):
49+ yield a
50+ a, b = b, a + b
51+
52+ def consume_generator():
53+ gen = fibonacci_generator(10000)
54+ for value in gen:
55+ temp1 = value + 1
56+ temp2 = value * 2
57+ temp3 = value - 1
58+ result = temp1 + temp2 + temp3
59+
60+ def main():
61+ while True:
62+ consume_generator()
63+
64+ _test_sock.sendall(b"working")
65+ main()
66+ ''')
6667 # Line numbers of the arithmetic operations in consume_generator.
6768 # These are the lines where fibonacci_generator should NOT be in the stack.
6869 # The socket injection code adds 7 lines before our script.
You can’t perform that action at this time.
0 commit comments