Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Tests appear to be running in alphabetical order for Raindrops

Ouverte
#2,214 8 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
python
Domaine
testing

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

discussion 💬 maintainer action required❕ smolder🍲

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

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de exercism/python

Toutes les issues de exercism/python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.