Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdb: import pdbcls lazily #5307

Merged
merged 1 commit into from
May 27, 2019
Merged

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented May 24, 2019

Fixes #2064.

]
)
assert result.ret == 4
assert result.ret == 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this delays the UsageError now, which is not handled too well by pytest (e.g. via exitcode).
IIRC UsageErrors are only handled during config parsing/setup.

@codecov
Copy link

codecov bot commented May 24, 2019

Codecov Report

Merging #5307 into master will increase coverage by 0.81%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #5307      +/-   ##
=========================================
+ Coverage   90.48%   91.3%   +0.81%     
=========================================
  Files         115     115              
  Lines       26258   26260       +2     
  Branches     2587    2588       +1     
=========================================
+ Hits        23760   23977     +217     
+ Misses       2159    1952     -207     
+ Partials      339     331       -8
Impacted Files Coverage Δ
testing/test_pdb.py 98.83% <100%> (ø) ⬆️
src/_pytest/debugging.py 89.83% <100%> (+0.1%) ⬆️
testing/python/fixtures.py 89.69% <0%> (-3.1%) ⬇️
testing/python/metafunc.py 92.04% <0%> (-2.2%) ⬇️
src/_pytest/python.py 92.13% <0%> (-0.97%) ⬇️
src/_pytest/fixtures.py 97.93% <0%> (+0.27%) ⬆️
src/_pytest/pytester.py 85.69% <0%> (+1.13%) ⬆️
src/_pytest/terminal.py 91.21% <0%> (+1.39%) ⬆️
testing/test_session.py 19.62% <0%> (+1.89%) ⬆️
src/_pytest/config/findpaths.py 95% <0%> (+2%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e393a73...f2ed796. Read the comment docs.

@blueyed blueyed requested a review from nicoddemus May 26, 2019 13:57
class PytestPdbWrapper(cls._pdb_cls, object):
pdb_cls = cls._import_pdb_cls()

class PytestPdbWrapper(pdb_cls, object):
Copy link
Contributor Author

@blueyed blueyed May 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile @nicoddemus
I'd also like to move the PytestPdbWrapper class out of the method, likely into a method that gets it cached based on pdb_cls then (typically only one cache entry then).
This is good for less overhead in general, but allows for testing if the returned instance is the same as before (useful for pdbpp's global pdb handling).
This should be done before 5.0 to avoid conflicts in this area.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds reasonable. I suspect this started as a small class so it was put inside the method for tersiness, but it has grown quite a lot since then.

Please do it right after this gets merged. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #5319.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

class PytestPdbWrapper(cls._pdb_cls, object):
pdb_cls = cls._import_pdb_cls()

class PytestPdbWrapper(pdb_cls, object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds reasonable. I suspect this started as a small class so it was put inside the method for tersiness, but it has grown quite a lot since then.

Please do it right after this gets merged. 👍

@nicoddemus nicoddemus merged commit ece774f into pytest-dev:master May 27, 2019
@blueyed blueyed deleted the lazy-pdb_cls branch May 27, 2019 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when attempting to use IPython debugger
2 participants