pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
12.09k stars 2.68k forks source link

py.test takes forever to print traceback on large files with unparseable statements #208

Closed pytestbot closed 9 years ago

pytestbot commented 12 years ago

Originally reported by: Maciej Fijalkowski (BitBucket: fijal, GitHub: fijal)


Steps to reproduce:

#!bash
hg clone https://bitbucket.org/pypy/pypy
cd pypy
hg up 39e70d282074
py.test pypy/jit/backend/llgraph -xv

see it take forever

this is the patch I'm using right now:

http://paste.pound-python.org/show/27012/

which somehow mitigates the issue (it still takes a long time, but not forever). an alternative would be to use _ast module to inspect where the statement starts and ends


pytestbot commented 12 years ago

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


i wrote a little patch for py to make use of _ast (which does come with its own sets of issue requiring some heuristic - but less prone to performance issues).

can you use the patch and report back any open issues?

pytestbot commented 12 years ago

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


patch to use the _ast module for discovering sttement boundaries - should greatly speedup tracebacks on average

pytestbot commented 12 years ago

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue208 and fix issue29 - avoid long pauses in traceback printing by using the new getstatementrange() code of the py lib which uses AST-parsing rather than the previous heuristic which had O(n^2) complexity (with n = len(sourcelines))

pytestbot commented 12 years ago

Original comment by Maciej Fijalkowski (BitBucket: fijal, GitHub: fijal):


being completely anal, I claim the complexity of the previous solution is O(n^3) :-) It moves the start, the end and deindenting a piece of code also takes O(n) ;-)