Tests appear to be running in alphabetical order for Raindrops
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par raindrops_test.py et reproduisez l’ordre avec pytest -x raindrops_test.py. Comparez l’ordre alphabétique observé avec les définitions des tests et avec le paramètre unittest.TestLoader.sortTestMethodsUsing essayé. C’est terminé lorsque les tests de l’exercice s’exécutent dans la progression prévue, ou lorsque le dépôt dispose d’une alternative documentée et cohérente.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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:
pytest -x raindrops_test.py
With the unchanged stub file in place, I get the following failure:
def test_2_to_the_power_3_does_not_make_a_raindrop_sound_as_3_is_the_exponent_not_the_base(
self
):
> self.assertEqual(convert(8), "8")
E AssertionError: None != '8'
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:
def test_the_sound_for_105_is_pling_plang_plong_as_it_has_factors_3_5_and_7(self):
> self.assertEqual(convert(105), "PlingPlangPlong")
E AssertionError: '8' != 'PlingPlangPlong'
E - 8
E + PlingPlangPlong
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:
unittest.TestLoader.sortTestMethodsUsing = None
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.
def test_01_the_sound_for_1_is_1(self):
- Langage dominant
- Python
- Étoiles
- 2.5k
- Forks
- 1.5k
- Merge moyen
- 25 min
- PR mergées (30 j)
- 1
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de exercism/python
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
-
[THIS IS SPAM] pythonOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 1/100
-
[General Docs] Audit/Cleanup of Track General/Shared DocsPeut-être à nouveau libre @BethanyG l’a pris il y a 106 jours, et aucune pull request n’est ouverte. Ouverte
exercism/python#4237 · 8 commentaires · 1 personne assignée ·
-
[Exercise Approaches]: Audit/Cleanup of Track Approaches 2026 (part 2)Peut-être à nouveau libre @Yrahcaz7 l’a pris il y a 137 jours, et aucune pull request n’est ouverte. Ouvertex:rep/massive
exercism/python#4197 · 25 commentaires · 2 personnes assignées ·
-
[Decimals]: New Concept and Concept ExercisePeut-être à nouveau libre @BethanyG l’a pris il y a 469 jours, et aucune pull request n’est ouverte. Ouverte
exercism/python#3928 · 1 commentaire · 1 personne assignée ·
Toutes les issues de exercism/python
Issues similaires
-
feature:LinkChecker
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
digitalfabrik/integreat-cms#4594 ·
Les mainteneurs répondent en général sous 5 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
EleutherAI/lm-evaluation-harness#4319 ·
Les mainteneurs répondent en général sous 1 jour
-
needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Peut-être pris @mayureshsonawane17 l’a pris aujourd’hui. OuverteWaiting for: Product Owner
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 5 jours