-
Notifications
You must be signed in to change notification settings - Fork 213
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
Wrong dynamic context
output for setup_class
and teardown_class
#658
Comments
The same things happens for Minimal reproducer: def setup_module():
pass
def teardown_module():
pass
def setup_function(function):
pass
def teardown_function(function):
pass
def test_A():
pass
def test_B():
pass
def test_C():
pass |
Isn't it the case that If you had only run |
Thank you for explanation. def setup_D():
pass
def B():
pass
class TestClass:
def setup_class(self):
setup_D()
def test_A(self):
pass
def test_B(self):
B() If As far as I understand, from user point of view, the purpose/motivation of "dynamic context" is to see "which test run this line". In this case, "dynamic context" has failed to capture the fact that Does this align with "dynamic context" feature scope? I wonder if this is technically impossible, or requires significant change of the algorithm to make it work, or simply doesn't match the intention. |
The dynamic context can only record what actually happens while running the code. That's what the word dynamic means there. I added print statements to your code:
Running it with pytest:
Yes, |
Oh, so it is a feature, not a bug 🙂. It is just how dynamic context works. The "dynamic context" feature provides the trace data as-is. So that's why context of Processing them to connect theses traces together is the work for another plugin, and therefore beyond the scope of Thank you, I understand now. |
Summary
Wrong
dynamic context
output forsetup_class
andteardown_class
, compared tosetup_method
.P/s: the same happened for
setup_module
compared tosetup_function
Note: this is not frontend issue, I think it might related to
coverage.sqldata::CoverageData::contexts_by_lineno
function.Reproducer
Expected vs actual result
Notice that
setup_class
only hastest_class.py::TestClass::test_A|setup
, while I expect it to either:setup_method
,test_class.py::TestClass::|setup
.The same problem exists for
teardown_class
.Actual result
Expected result
by photoshoping, of course
Version
Not related but I need this fixed to do nedbat/coveragepy#1856
The text was updated successfully, but these errors were encountered: