-
Notifications
You must be signed in to change notification settings - Fork 135
Adjust duration_by_test definition to reflect new use #429
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
Adjust duration_by_test definition to reflect new use #429
Conversation
45c1e84 to
5ab6b77
Compare
|
Thanks for your investigation! It looks good, but I think we should (re)set the duration to 0 at the test start instead of using a defaultdict. I am not sure if it is an issue currently, but maybe we could run the stats collection twice, or load existing stats from the json. Without resetting the duration to 0, we would collect some test duration in the first run, and in the second run we would add to the test duration instead of starting again from 0. I think we could use the pytest_runtest_logstart hook to set the value to 0 (I think this hook is called at the start of the test, see https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest.hookspec.pytest_runtest_protocol) |
|
@Otto-AA - are you meaning between different test runs? If so, isn't that (at least currently) mitigated by only passing the StatsCollector plugin to the stats-collection test run? |
|
I'm thinking about what happens when This could happen if we call Line 799 in 5ab6b77
But it's easier to verify, and less likely to break in the future, if we set |
|
@Otto-AA , does that latest commit "Reset test duration at start of each test" do what you were thinking of? |
|
Yes, looks good. Feel free to merge it if the stats still works with the reset (I can't test it locally). You could also make the defaultdict a dict again if you want, it should work either way. |
As at the status quo, whichever call item ran last (usually 'teardown') had its time overwrite the test in question's entry in duration_by_test. The simplest way I could think of to avoid that was to add each call item's duration to the total in duration_by_test. Changing duration_by_test to a defaultdict simplified the bookkeeping.
After comments by @Otto-AA, who pointed out that although my changes are good _now_, they would be less likely to break in future if we explicitly reset the accumulated test duration, so this commit does just that.
64189d8 to
b7552f5
Compare
|
I kept the defaultdict, following your "belt-and-braces" philosophy, @Otto-AA . |
As at the status quo, whichever call item ran last (usually 'teardown') had its time overwrite the test in question's entry in duration_by_test.
The simplest way I could think of to avoid that was to add each call item's duration to the total in duration_by_test. Changing duration_by_test to a defaultdict simplified the bookkeeping.