-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
minesweeper: update tests to version 1.1.0 #1062
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
Conversation
# self.assertEqual(board([]), []) | ||
|
||
# def test_no_columns(self): | ||
# self.assertEqual(board([""]), [""]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please give a more detailed explanation for why these tests are disabled? I don't like setting a precedent for skipping/disabling canonical tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally this was because the implementation of the board class uses the verify_board function to reject boards without the border or no rows/columns but the canonical data looks like it expects a return of the board as is for both of these cases.
If we'd be okay with it, I can reenable both of these cases but convert both into checks that the board class raises a ValueError in response to the board type instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that you re-enable the disabled test cases, but instead of converting the tests, can we simply do away with the verify_board
method? There is no requirement in either the canonical data or the description that the solution needs to validate the board; it is merely meant to convert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove the verify_board method from the example implementation, but I think it would necessitate removing a few of the additional test cases as well (the final 3 that test malformed boards).
I think it may be desirable to have a verify_board method though. If there's no restriction on the input being a well formed board especially cases with rows/columns of differing sizes it may be hard to decide what's truly adjacent to a mine thus complicating generating output.
It also seems like the no row/no column board with no border might not be valid given that all the boards in the problem description and old test set always include a drawn border.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, these don't look like valid boards to me, given the borders present in all other examples, so I would expect these to raise ValueError
s. Ultimately, I don't mind whether these tests are modified or removed - I don't think that they add anything to what we already have.
@cmccandless, I like the inclusion of board verification, and I don't think that it makes sense to remove it in order to better match the canonical data for two trivial cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy for this to be merged once the version string is moved down a line (I love consistency), and the currently commented tests are either removed or changed to check that a ValueError
is raised.
@@ -10,114 +10,158 @@ | |||
|
|||
from minesweeper import board | |||
|
|||
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smalley, can you move the version comment down by a line for consistency? (ie. two blank lines before, one after)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no problem at all @N-Parsons, I can make that change and push an update.
Having looked at this again, I noticed that the canonical data doesn't have the borders. @cmccandless, what are your thoughts on removing the borders? |
Add missing test version comment. Add ordered tests with names matching canonical data descriptions. Disable empty board tests which are incompatible with board class. Move selected old tests to additional tests section. Convert no row/column tests to expect validation to raise ValueError. Closes exercism#998
I updated this pull request to convert the first two tests to expect ValueError to be raised and uncommented them. If we want to remove the border or convert the no row/ no column tests to have borders we can definitely do those as well. |
@N-Parsons if the canonical data does not have borders, then I don't think the tests should have them. If this change were made, do we have any reason to keep the board validation? |
Ok, I agree that we should remove the borders. I think that without the borders, the validation becomes too trivial to really worry about making people implement, so I think that it can be removed as well. @smalley, are you happy to make these changes? |
@N-Parsons sure, I can work on making those changes to the boards and remove the validation function |
@N-Parsons |
exercises/minesweeper/example.py
Outdated
@@ -31,9 +33,3 @@ def verify_board(inp): | |||
cset.update(r) | |||
if cset - set('+- *|'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second set should be set(" *")
now, since the other elements were for the border.
Thanks @smalley, I've left a comment about a very minor issue the example solution (the set of valid characters needs updating). Once that's fixed, I think this will be ready to merge. @cmccandless, can you review this again? |
Update test data to borderless format which matches canonical data format. Change board verification to not test for borders and default example to properly return a completely empty board and account for new index when there is no border.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Looks good. Thanks, @smalley! |
Add missing test version comment.
Add ordered tests with names matching canonical data descriptions.
Disable empty board tests which are incompatible with board class.
Move selected old tests to additional tests section. Closes #998