-
Notifications
You must be signed in to change notification settings - Fork 15
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
Expose ProcessDispatcher._get_process
as a public API or return a Popen
result from register(...)
#79
Comments
Thanks for raising an issue. It's a fair point, and I'll think about how should I approach it. |
I suggest returning a proxy object from It's the most non-invasive architecturally, from what I've seen so far. And, as a bonus, it's pretty intuitive to use. I might be able to PR this, as I'm using |
I think it should have a list of Popen instances, as one I'll probably work on it during the weekend (no promises), but if you want to tackle it, let me know and I'll wait for your PR. |
Hi, sorry for a late response. I'm still trying to grasp all of the implications of this and find the best way to fit it into tests. I think it does tick the boxes in the functionality department, but I'm not 100% sure about the usability of it yet. E.g. there's at least one ugly usability oddity that this kind of design encourages. If I'm testing for signals, and I want the exceptions to be helpful for anyone debugging, I have to assert twice: first to check that the process has been called at least once, secondly to test the signal. Either I copy the first assert to every test that does a check like this, or I fall into a trap: tests will raise a confusing It would be nice if the indexing was done for me internally instead, and if there was no call - a custom exception with proper message was raised. Here's what I imagined could be a step in the right direction:
Augmenting the returned (list-like) object with these kinds of amenities greatly helps readability too. This idea is compatible with returning something that can be indexed: the indexing is still worthwhile for someone who tests for a number of calls. |
Thanks for the feedback, I see your point. I didn't release the new version yet, so it's OK to modify it. Now, once the If you could propose a PR with your vision of the object it would be great, if not then I can work on it, but it probably won't be in this month. I think we can modify the API and instead of having the object indexable, it should expose something like |
Yes, I would see that as a better approach. In my previous comment I evaluated the design as implemented on
I'll try to do so if the time permits, next week perhaps. Please share any suggestions and use-cases you might have on your mind, I'll do my best to accommodate them. |
I have no suggestions except to have the list of calls in a separate |
@MrMino - are you still intend to submit your suggestions, or should I give it another take? |
Sorry, I wasn't able to find the time for it. You can take it. |
@MrMino - the |
It is impossible to properly unit-test functionalities like sending a signal, when the tested class facades
subprocess.Popen
without exposing the resulting process object. Rummaging in class internals during unit tests is a bad practice which leads to brittle testcases.It would be nice if
pytest-subprocess
had a way of getting the result of fakedPopen
(or its proxy). That way we could assert some side effect without having to extract thePopen
result from the unit under test:The text was updated successfully, but these errors were encountered: