Skip to content

Commit 6c0e7fb

Browse files
committed
Address Ivona's review
1 parent 3618abb commit 6c0e7fb

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

Lib/test/test_profiling/test_sampling_profiler/test_blocking.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for blocking mode sampling profiler."""
22

33
import io
4+
import textwrap
45
import unittest
56
from 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.

0 commit comments

Comments
 (0)