-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Tests appear to be running in alphabetical order for Raindrops #2214
Comments
I did a search, and it looks like there has been some discussion about this previously: |
@yawpitch said in #1853 (comment):
My quite take on this is that, while that's true and there are lots of places that the tests may not have been ordered correctly, there are also a significant amount of places where they have been deliberately ordered and where that order greatly improves the learning experience. So there is value to respecting the order, although it will not always be beneficial, and I can't see the downside of not respecting the order. If that is accurate, then the only negative of implementing some solution that respects the order is that (as outlined in #1853 and other places) there's not a particularly clean solution. However, I would argue that an ugly solution is better than not having ordering. So, pending someone willing to do the work, I think this is a change we should make. |
Piping in to explain: the technical reason we never did this is because To reliably get line order you need to set the All of that, and the fact that it just generally seems a bad idea to imply to students that they should expect a fully curated sort order in the real world of Python development, has weighed against this change. Now, yes, another simpler way would be to add to the templates some test name generator logic that would introduce a sorting number (so each test method would be generated as “test_0001_some_aspect”, “test_0002_some_other_aspect”, etc), but we’d have to ensure zero padding for unknown numbers of tests, and we’ve already got a problem with overlong test names. |
@yawpitch Thanks for explaining :) In #1853 you mused about pytest saying:
Is there a (good enough) reason not to use pytest as the "blessed" runner? I believe many other tracks do have a specific test runner that they advocate (the JS family as an example). It sounds like this would simplify the situation and maybe give us a cleaner solution? But I don't know enough about Python to understand the tradeoffs. |
Reasons not to restrict to single test runner (I don't know if any of them are "good enough"):
|
These exercises are supposed to teach the basics, so I think it makes more sense to have just unittest usage explained to avoid the issue of people having to figure out how to install pytest. I don’t really see the benefit of pytest over unittest here, other than slightly prettier output. If someone is already familiar with another runner, I would think they’d know how to use it already regardless. |
This issue has been automatically marked as |
I am going to re-open this issue. In light of V3 changes that now depend on We now have dependancies on
Not going to go into ordering atm, but pytest-order and pytest-ordering as plugins to PyTest look interesting as options. |
I tried out a couple of exercises on the Python track today, and noticed with the Raindrops exercise in particular that the tests were requiring me to implement the entire algorithm on the second failure.
I'm working in Python 3.8.5.
I run the tests with the following command:
With the unchanged stub file in place, I get the following failure:
This is a reasonable "first" failure, since it's a single number that should be turned into a string.
If I make that pass with a hard-coded
return "8"
, then this is the next failure I get:Looking at the tests, the order that they are defined in is quite nice, in terms of pushing the implementation forward step by step.
I tried adding the following declaration after the
import unittest
statement, to see if this would cause the tests to be run in the order that they are defined:This did not change the order that the tests are run in.
If I sort the tests alphabetically by name, it appears to correspond to the order that I'm seeing when doing the exercise:
While under normal circumstances I would want tests to be run in random order, in Exercism exercises I think that it would make more sense to run the tests in the order that they are defined.
Is there a declaration we can make in order to accomplish this?
If not, then I would propose that we rename tests by adding a numeric prefix to the test name (e.g.
The text was updated successfully, but these errors were encountered: