Skip to content

Conversation

@furkanonder
Copy link
Contributor

@furkanonder furkanonder commented Apr 27, 2023

Co-authored by: Andrea Crotti

stats_file = support.findfile('pstats.pck')
self.stats = pstats.Stats(stats_file)
to_compile = 'import os'
self.temp_storage = tempfile.mktemp()
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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


def test_load_equivalent_to_init(self):
empty = pstats.Stats()
empty.load_stats(self.temp_storage)
Copy link
Member

Choose a reason for hiding this comment

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

It seems like your new tests both dump to and load from this temp file, functionality wise it works for now, but I think we should "isolate" the tests as much as possible? Reordering the execution of the tests could cause this load_stats to load different files - it could be the file created at setUp, or it could be the file created in test_dump_and_load_works_correctly. Again, it works because the test does not care what's in the file, as long as it's valid, it's just a bit convoluted. It seems like the profile created in setUp is only (potentially) used in this test? Maybe consider to move that piece into the unittest directly? The other test will overwrite thie file anyway I assume?

Copy link
Contributor

Choose a reason for hiding this comment

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

@furkanonder furkanonder changed the title GH-57879: Increase test coverage for pstats.py gh-57879: Increase test coverage for pstats.py Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants