-
Notifications
You must be signed in to change notification settings - Fork 9
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 hook for custom tests in test yaml #184
Comments
we do a lot of custom tests to do file diffs which are more informative than a simple md5 checksum. I did some brainstorming a while ago that was along the line of what you're thinking here although maybe not quite as general. I like your idea of using the built-in pytest mechanisms to mark or "register" these custom tests, so that pytest-workflow doesn't have to do the job of figuring out where these things live. |
I do appreciate suggestions such as this. The custom test interface is a bit clunky indeed as it uses the workflow name to figure out the directory and nothing more. However, this code has to work within technical constraints as well. The major technical constraint here is the pytest API. It is not easy to flow information from the YAML to the "mark" interpreter. The project is already quite complex as it is. Complexity breeds bugs and having the test framework as bug-free as possible is absolutely essential. A test framework that throws errors on its own accord is much less useful as a good testing tool. Custom validators are probably only a small percentage of your workflow tests. So while I think it would be convenient to have a feature such as this, I don't think it would merit the technical complexity that it adds to the project. |
I have been thinking a bit about this. How about something like this:
Test funcs should be defined in some file. The test func will be called with the following arguments:
This leaves the YAML simple, it also explicitly couples workflow tests to defined functions. It is much less clunky than using the The implementation is not going to be trivial though. @DavyCats @Redmar-van-den-Berg also curious to your thoughts on this issue. |
I'm not sure this would be an improvement. In the current situation, the custom tests get the workflow name, and you have to go search in the .yml files to find which workflow they refer to. I quite like the current system, it is very straightforward. You get the workflow directory in your custom tests, and from there you can have your tests do whatever you want. Especially since the custom tests no longer run if the workflow itself fails, you can always trust that all expected files will exist. |
@Redmar-van-den-Berg thank you for your observations. You are right that this solution merely moves the problem rather than solving it. So I won't implement that particular solution. |
it would be convenient if the custom test infrastructure interfaced with the test.yml file so that certain files could be validated using custom test code rather than one of the built in validation methods. This can already be achieved with the custom test infrastructure, but that requires encoding information about the desired test results in two separate places (in the custom test and in the test.yml. If the test yml could hook custom tests then all the expected output information could be kept in the same place. For example:
test.yml
tests/test_custom_validators.py
The text was updated successfully, but these errors were encountered: