<#20311 Running Python test under pyinstrument or ...
# github-notifications
c
#20311 Running Python test under pyinstrument or other custom executable New discussion created by eguiraud Hello, I have some Python tests (typically run with
pants test ...
) that I sometimes would like to run under a profiler such as
pyinstrument
, or
cProfile
, and some other times even under a C/C++ debugger like
gdb
in order to break into problematic logic in a given extension module. What is the simplest way to do so? What I am doing at the moment: • change
BUILD.pants
file to add a
pex_binary
rule for the
python_test
rule that I want to instrument/debug • change the test to make it run the test what it's run as a standalone Python executable by adding an invocation to the test function under
if __name__ == "__main__"
• run
pants package
for the
pex_binary
target •
gdb --args python ./dist/path/to/target.pex
now seems to work pantsbuild/pants