3👍
✅
First, It appears that there is a problem to the url. I think it should be
class TestLogout(TestCase):
def test_logout(self):
self.client = Client()
response = self.client.get('/cost_control/logout/')
Also, I suggest to do login the user first. So,
class TestLogout(TestCase):
def test_logout(self):
self.client = Client()
# Assuming there is a user exists in tests db
# or make a user like.
# User.objects.create_user(username='fred', email='test@test.com', password='secret')
self.client.login(username='fred', password='secret')
response = self.client.get('/cost_control/logout/')
self.assertEqual(response.status_code, 302)
For running coverage, you can do:
coverage run --source=.,cv_manage manage.py test
where –source = [all apps]
this can also be configured in .coveragerc
Source:stackexchange.com