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

Add duration information to tests #106

Open
jvperrin opened this issue Nov 22, 2017 · 2 comments
Open

Add duration information to tests #106

jvperrin opened this issue Nov 22, 2017 · 2 comments

Comments

@jvperrin
Copy link
Member

Having duration information like in ocfweb would be nice, however currently it doesn't work because of freezegun. I think some more debugging is needed to get the two working well together (or maybe file an issue/PR on either pytest or freezegun). The current output is something like this, which is obviously false:

============================================= slowest 10 test durations ==============================================
71063314.99s teardown tests/lab/hours_test.py::TestDay::test_creation[None-Saturday-None-hours5]
71063314.92s teardown tests/lab/hours_test.py::TestDay::test_creation[when4-Sunday-Random 3 Days-hours4]
71063314.84s teardown tests/lab/hours_test.py::TestDay::test_creation[when3-Saturday-Pi Day-hours3]
71063314.77s teardown tests/lab/hours_test.py::TestDay::test_creation[when2-Wednesday-None-hours2]
71063314.70s teardown tests/lab/hours_test.py::TestDay::test_creation[when1-Sunday-None-hours1]
71063314.63s teardown tests/lab/hours_test.py::TestDay::test_creation[when0-Sunday-None-hours0]
71063314.51s teardown tests/lab/hours_test.py::test_is_open[now12-False]
71063314.43s teardown tests/lab/hours_test.py::test_is_open[now11-True]
71063314.36s teardown tests/lab/hours_test.py::test_is_open[now10-True]
71063314.29s teardown tests/lab/hours_test.py::test_is_open[now9-True]

A possible workaround I suppose would be to make the time used in the freezegun mock something long in the future so that the time is then negative? Doesn't seem great though :(

@jvperrin
Copy link
Member Author

Just adding a pytest.ini file with these contents makes it show the duration information, but it won't be accurate until the above issue is fixed:

[pytest]
addopts=--durations=10

@dkess
Copy link
Member

dkess commented Mar 18, 2019

Looks like there's an effort to get this fixed upstream, see spulec/freezegun#288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants