hjwp / hjwp/Book-TDD-Web-Dev-Python
Page 226: `lists/tests/test_model.py`
- Lingua principale
- Python
- Stelle
- 514
- Fork
- 175
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
It's a bit confusing when you write:
```python
item.save()
item.full_clean()
```
while the name of the tests is `test_cannot_save_empty_list_item`
Because in the end... _the item is saved_. It can be verified by putting the following right after the with block:
```python
self.assertEqual(Item.objects.count(), 0)
```
**Two potential solutions**
- Maybe just swapping the order of the 2 lines might make things less confusing :)
```python
item.full_clean()
item.save()
```
- Another solution would be to simply rename the tests from `test_cannot_save_empty_list_item` to `test_cannot_validate_empty_list_item`
And removing the call to `save()` alltogether.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Apri lists/tests/test_model.py e esamina i test denominati test_cannot_save_empty_list_item, insieme alle chiamate item.save() e item.full_clean(). Confronta l’approccio proposto per l’ordinamento o la ridenominazione, quindi verifica la formulazione e il comportamento scelti con la suite di test; il lavoro è completato quando il nome del test descrive accuratamente la validazione o il salvataggio e conferma se un elemento è stato persistito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- testing
- Tipo di issue
- Refactoring
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100