hjwp / hjwp/Book-TDD-Web-Dev-Python

Page 226: `lists/tests/test_model.py`

Open
#115 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
514
Forks
175
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.