Parametrize test_workspacecreateform_success
#4654
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, we make a couple of small changes to two tests. These small changes help us see that the two tests are basically the same, save for two parameters. We then parameterise one test and remove the other, meaning we have the same tests for 14 fewer lines of code.
We use the
pytest.mark.parametrize
decorator to parameterise the test, also usingpytest.param
to assign a more descriptive ID to each parameter set. Doing so also makes it easier to run the test with either parameter set:Or with both parameter sets:
Although out of scope, I think it's worth noting that
test_workspacecreateform_success
would be a great candidate for property-based testing. It's unlikely that everyname
will be either lower-case or mixed-case ASCII in real life, so verifying thatWorkspaceCreateForm.clean_name
works correctly with a wide range ofname
s is important.I created this PR whilst working on #4593. It doesn't address that issue, but it does make that issue easier to address.