-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
twelve-days: re-implement according to canonical data #1306
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
"a Partridge in a Pear Tree.\n\n" | ||
class LyricsTests(unittest.TestCase): | ||
def test_first_three_verses_of_the_song(self): | ||
expected = ["On the first day of Christmas my true love gave to me, " |
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.
Since there are other tests verifying correct output from recite(n, n)
, I think the following would be adequate:
expected = [recite(n, n) for n in range(1, 4)]
This also removes the need for large redundant text blocks.
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.
@cmccandless Pretty nice trick! But since recite
returns a list of one string, we should capture its first element:
expected = [recite(n, n)[0] for n in range(1, 4)]
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.
On the idea of nice tricks...
expected = sum([recite(n, n) for n in range(1, 4)], [])
Not really any neater than what you're already doing, and it's not as readable, so please don't use that for this exercise.
self.assertEqual(recite(1, 3), expected) | ||
|
||
def test_three_verses_from_the_middle_of_the_song(self): | ||
expected = ["On the fourth day of Christmas my true love gave to me, " |
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.
Again, expected = [recite(n, n) for n in range(4, 7)]
|
||
def test_the_whole_song(self): | ||
self.assertEqual(verses(1, 12), sing()) | ||
expected = ["On the first day of Christmas my true love gave to me, " |
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.
Again, expected = [recite(n, n) for n in range(1, 13)]
Closes #1221. Re-implement this exercise according to canonical data.