[py-dev] using Python profiler with py.test

Matthew Scott mscott at goldenspud.com
Thu Mar 3 20:39:21 MET 2005


I'm having problems using the Python profiler with py.test

If I write a simple one-liner as 'hello.py':

   import py; print py.path.local()

Then run "python2.4 -m profile hello.py", I get a report from the profiler.

However, if I run "python2.4 -m profile bin/py.test" from within the py 
directory, I get the output below.

Any ideas or tips on using the Python profiler with py.test?


inserting into sys.path: /home/gldnspud/s/py-dist
============================= test process starts 
=============================
testing-mode: inprocess
executable  : /usr/bin/python2.4  (2.4.1-alpha-0)
using py lib: /home/gldnspud/s/py-dist/py <rev unknown>
Traceback (most recent call last):
   File "/usr/lib/python2.4/profile.py", line 611, in ?
     run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort)
   File "/usr/lib/python2.4/profile.py", line 72, in run
     prof = prof.run(statement)
   File "/usr/lib/python2.4/profile.py", line 448, in run
     return self.runctx(cmd, dict, dict)
   File "/usr/lib/python2.4/profile.py", line 454, in runctx
     exec cmd in globals, locals
   File "<string>", line 1, in ?
   File "bin/py.test", line 5, in ?
     main()
   File "/home/gldnspud/s/py-dist/py/test/cmdline.py", line 32, in main
     run.inprocess(args, filenames)
   File "/home/gldnspud/s/py-dist/py/test/run.py", line 141, in inprocess
     driver.run(fncollectors)
   File "/home/gldnspud/s/py-dist/py/test/drive.py", line 41, in run
     self.reporter.start()
   File "/home/gldnspud/s/py-dist/py/test/report/text/reporter.py", line 
53, in start
     self.out.line("initial testconfig %d: %s" %(i, x))
   File "/home/gldnspud/s/py-dist/py/path/extpy/extpy.py", line 38, in 
__str__
     def __str__(self):
   File "/usr/lib/python2.4/profile.py", line 238, in trace_dispatch_i
     if self.dispatch[event](self, frame, t):
   File "/usr/lib/python2.4/profile.py", line 295, in trace_dispatch_call
     assert (self.cur is None or \
AssertionError: ('Bad call', ('/home/gldnspud/s/py-dist/py/initpkg.py', 
149, '__getattr__'))


-- 
Matthew R. Scott


More information about the py-dev mailing list