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 --onstart similar to --onexit #32

Closed
bendtherules opened this issue Dec 3, 2015 · 1 comment
Closed

Add --onstart similar to --onexit #32

bendtherules opened this issue Dec 3, 2015 · 1 comment

Comments

@bendtherules
Copy link
Contributor

ptw currently has --onexit, but no --onstart - There should be no reason for this asymmetrical design. There is already --beforerun, but it is run before every run of pytest and so, isn't a good candidate for initialising something just once.

It can be useful for starting things like a external notifier, which wants to run for the whole duration of ptw.

Adding it should be trivial.

@bendtherules bendtherules changed the title Add --onstart similar to --onexit Add --onstart similar to --onexit Dec 3, 2015
@joeyespo
Copy link
Owner

joeyespo commented Dec 4, 2015

Unlike the --onexit option, there isn't a strong case for its dual aside from the purity of symmetry.

--onstart can be accomplished outside of ptw pretty easily (such as myscript && ptw). However, --onexit solves a practical problem where you need to run some explicit cleanup code before terminating from an external script environment, e.g. a Makefile or npm run. (In retrospect, --finally may be a better name than --onexit to match the common try-finally concept. This name might better indicate that there isn't some "missing" dual feature.)

Symmetry is a nice property to have in theory and mathematics, but it can easily lead to over-engineering and clutter if there's no other purpose. Adding a feature is usually much easier than maintaining it, so triviality isn't exactly a good indicator of necessity.

Thanks for the suggestion.

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