22import multiprocessing
33import os
44import sys
5+ from typing import cast
56
67import pytest
78
@@ -21,9 +22,9 @@ def test_call_script(monkeypatch):
2122 assert exitcode == 0 , (stdout , stderr )
2223 else :
2324 assert exitcode == 42 , (stdout , stderr )
24- hello , interval , _ = list (s .strip () for s in stdout .decode ().strip ().split ("\n " ))
25- assert hello == "hello world" , stdout .decode ().strip ()
26- assert float (interval ) >= 0.01 , stdout .decode ().strip ()
25+ hello , interval , _ = list (s .strip () for s in cast ( bytes , stdout ) .decode ().strip ().split ("\n " ))
26+ assert hello == "hello world" , cast ( bytes , stdout ) .decode ().strip ()
27+ assert float (interval ) >= 0.01 , cast ( bytes , stdout ) .decode ().strip ()
2728
2829
2930@pytest .mark .skipif (not os .getenv ("DD_PROFILE_TEST_GEVENT" , False ), reason = "Not testing gevent" )
@@ -51,7 +52,7 @@ def test_call_script_pprof_output(tmp_path, monkeypatch):
5152 assert exitcode == 0 , (stdout , stderr )
5253 else :
5354 assert exitcode == 42 , (stdout , stderr )
54- hello , interval , pid = list (s .strip () for s in stdout .decode ().strip ().split ("\n " ))
55+ hello , interval , pid = list (s .strip () for s in cast ( bytes , stdout ) .decode ().strip ().split ("\n " ))
5556 utils .check_pprof_file (filename + "." + str (pid ))
5657
5758
@@ -61,11 +62,9 @@ def test_fork(tmp_path, monkeypatch):
6162 monkeypatch .setenv ("DD_PROFILING_API_TIMEOUT_MS" , "100" )
6263 monkeypatch .setenv ("DD_PROFILING_OUTPUT_PPROF" , filename )
6364 monkeypatch .setenv ("DD_PROFILING_CAPTURE_PCT" , "100" )
64- stdout , stderr , exitcode , pid = call_program (
65- "python" , os .path .join (os .path .dirname (__file__ ), "simple_program_fork.py" )
66- )
65+ stdout , _ , exitcode , pid = call_program ("python" , os .path .join (os .path .dirname (__file__ ), "simple_program_fork.py" ))
6766 assert exitcode == 0
68- child_pid = stdout .decode ().strip ()
67+ child_pid = cast ( bytes , stdout ) .decode ().strip ()
6968 utils .check_pprof_file (filename + "." + str (pid ))
7069 utils .check_pprof_file (filename + "." + str (child_pid ), sample_type = "lock-release" )
7170
@@ -74,7 +73,7 @@ def test_fork(tmp_path, monkeypatch):
7473@pytest .mark .skipif (not os .getenv ("DD_PROFILE_TEST_GEVENT" , False ), reason = "Not testing gevent" )
7574def test_fork_gevent (monkeypatch ):
7675 monkeypatch .setenv ("DD_PROFILING_API_TIMEOUT_MS" , "100" )
77- stdout , stderr , exitcode , pid = call_program ("python" , os .path .join (os .path .dirname (__file__ ), "gevent_fork.py" ))
76+ _ , _ , exitcode , _ = call_program ("python" , os .path .join (os .path .dirname (__file__ ), "gevent_fork.py" ))
7877 assert exitcode == 0
7978
8079
@@ -97,7 +96,7 @@ def test_multiprocessing(method, tmp_path, monkeypatch):
9796 method ,
9897 )
9998 assert exitcode == 0 , (stdout , stderr )
100- pid , child_pid = list (s .strip () for s in stdout .decode ().strip ().split ("\n " ))
99+ pid , child_pid = list (s .strip () for s in cast ( bytes , stdout ) .decode ().strip ().split ("\n " ))
101100 utils .check_pprof_file (filename + "." + str (pid ))
102101 utils .check_pprof_file (filename + "." + str (child_pid ), sample_type = "wall-time" )
103102
0 commit comments