Tests appear to be running in alphabetical order for Raindrops
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con raindrops_test.py y reproduce el orden usando pytest -x raindrops_test.py. Compara el orden alfabético observado con las definiciones de las pruebas y con la configuración intentada unittest.TestLoader.sortTestMethodsUsing. Se considera terminado cuando las pruebas del ejercicio se ejecutan en la progresión prevista, o cuando el repositorio tiene una alternativa documentada y coherente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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):
- Lenguaje dominante
- Python
- Estrellas
- 2.5k
- Forks
- 1.5k
- Merge medio
- 25 min
- PR fusionados (30 d)
- 1
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de exercism/python
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
-
[THIS IS SPAM] python Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 1/100
-
x:rep/massive
Todos los issues de exercism/python
Issues similares
-
essnmx good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
-
[Feature] 奇物选择添加优先级 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
syfoud/Simulated_Scepter#174 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Giskard-AI/giskard-oss#2840 · 1 comentario ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Abiertoarea: repo bug perceived difficulty: 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
yeti-platform/yeti#1380 ·