-
Notifications
You must be signed in to change notification settings - Fork 26
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 support for unittests (via pytest) #6
Comments
Can you clarify what's the error here? |
There are two most common ways how to write tests in Python:
This example illustrates both these ways: https://github.com/ChaoticRoman/pytest-monitor-example/blob/memray-example/tests/test_float.py The officially supported way is the one using This 40 lines long script does implement memory profiler with https://github.com/ChaoticRoman/pytest-monitor-example/blob/custom_memory_profiler/unittestit.py but it would be nice to have full support through a |
My question was why does it not support it? Doesn't just works? What happens if you try to use it? |
@gaborbernat It does not :( Memory allocation is reported for native pytests but not for unittests (although those are discovered and executed by pytest). Using the example referenced above:
|
Just +1 on this, i've tried this today with a package using
|
Although in all fairness the
I'm unclear what changes might be required to make this work with unittests but will do some reading. |
We use custom hooks, so unfortunately is very unlikely that we will be able to support it if pytest doesn't :( |
Needed to write tests using pytest fixtures instead of unittest due to this issue: bloomberg/pytest-memray#6
Needed to write tests using pytest fixtures instead of unittest due to this issue: bloomberg/pytest-memray#6
Adding support for splitting grib files by multiple dimensions at once. This commit does this by delegating the heavy lifting to ecCodes' `grib_copy` utility. * Refactored file_splitters_test.py for memray pytest plugin. Needed to write tests using pytest fixtures instead of unittest due to this issue: bloomberg/pytest-memray#6 * Proof of concept: using `grib_copy` for splits. * Updating CI to perform memory profiling. * Added a backwards-compatiable CLI option to choose new split impl. * Added default to pass tests. * Added default to pass type check. * WIP – figuring out dependencies. * Updated merged test to fit pytest format. * Secure subprocess run, defaulting to v2, style fixes. * Updated memory bounds for tests. * Implementing suggestions from @uhager. * Added link to docs on how to prepare a container image. * Updated readme, removes old flag. * Removed another trace of the flag from the README.md * Nit: grammar. * Nit: changed import style.
Closing this as purest doesn't allow us to do this easily |
Feature Request
Pytest can discover and run unittests but pytest-memray does not work on these. An example:
https://github.com/ChaoticRoman/pytest-monitor-example/tree/memray-example
There is an exactly same issue with alternative pytest memory profiler called pytest-monitor:
CFMTech/pytest-monitor#39
I made very simple memory profiler for unittests that can be helpful for someone encountering this issue:
https://github.com/ChaoticRoman/pytest-monitor-example/blob/custom_memory_profiler/unittestit.py
The text was updated successfully, but these errors were encountered: