Repository navigation
Enable high-scores "after" tests with a test helper - #3013
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
|
@IsaacG -
|
|
Actually @IsaacG, that last message was a massive brain fart on my part. I was pointed at the wrong repo! 😱 But this is failing in the test runner. Something about this is fouling up the code that navigates the AST and puts tests in order, so I will need to dig into that. |
|
Yeah. I saw that after I created the PR. Yet when I run the test runner locally (outside Docker), it's perfectly happy. If the template/helper approach seems reasonable, I can try and dig into those. Alternatively, I can try to solve this without a helper class. |
|
The quickest and easiest way would likely be to omit the helper class and do conditional logic in the test case selection, with a macro that treated immutability cases as "special", and added the extra function calls to catch if Something roughly along the lines of: if its an immutability case, then poop out the following: def test_latest_score_after_personal_top_scores(self):
scores = [70, 50, 20, 30]
expected = 30
temp_obj = HighScores(scores)
temp_obj.personal_top_three()
self.assertEqual(HighScores(temp_obj.scores).latest(), expected)The website uses the Docker container for tests, so its the Docker version that needs to work. The test runner sorting ceremony is ..brittle, and eventually needs to be replaced. It's intended to keep the tests in the order they're defined in the test file, but it's "solving" a problem that we may no longer need to have solved. However, I am not ready to jump into refactoring the test runner today....especially when it is only breaking for this one exercise. |
|
Sure! That seems a bit ... messier of an approach, but I can give it a spin. I'll update the PR when I got it working. |
|
This should handle all the tests in the canonical data, including the ones unsynced at the parent commit. |
|
... I'm not sure what's up with that Docker test runner 🤷 |
Yup. It is indeed messy. And you are welcome to make it more elegant....as long as it passes CI and runs in Docker correctly. 😉
Yup. Me either, really. With the day I've had, I am ... uninterested in getting into it. But when I get a block of time free, I am going to kill it with fire....er.....refactor the heck out of it. Thanks for submitting the updates! I'll take a look. |
BethanyG
left a comment
There was a problem hiding this comment.
Looks good...and it fails where it's supposed to when I call self.scores.sort(reverse=True) instead of using sorted(). Thanks for your work on this!
|
...and if you are feeling particularly masochistic, you can now submit a PR to add a |
|
Handling a |
|
See PR #3016 for the scores. I think I made it slightly cleaner ... but added a macro. |
|
That looks good ...BUT. We want the additional cases in a additional_tests.json file. Like this one for Those then get concatenated with the canonical data and run through the template. We shouldn't do a complete end-runaround via macro. As much as we'd like to. 😉 |
|
Then again, the way you've done it does call HighScores.scores, and is effectively the same test cases.... 🤔 |
|
I'm not following. All these tests are implementing test cases from the canonical data. Aren't additional tests for tests which are not pulled from the canonical data? |
No description provided.