27
loading...
This website collects cookies to deliver better user experience
python manage.py test
:class IndexPageTests(TestCase):
def test_request_index_page(self):
'''
Make sure the homepage is reachable
'''
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
def test_post_creation(self):
'''
Make sure the post creation is working
'''
create_post('Test title', 'Test text')
self.assertTrue(Post.objects.filter(title='Test title').exists())
def test_posts_are_visible(self):
'''
Make sure the posts are visible on the index page
'''
create_post('Test title', 'Test text')
response = self.client.get('/')
self.assertContains(response, 'Test title')
requirements.txt
file which contains all of your projects dependencies. pip
can quickly generate this for you by running $ pip freeze > requirements.txt
from inside your virtual environment. For a better understanding of the beauty of a venv, this article is excellent.requirements.txt
in your root directory, go to your GitHub repo, click GitHub actions and select Django. This will create a .github/workflows/django.yml
file which tells GitHub how to test your codebase. Due to some incompatibilities, I was unable to get my code to pass using python 3.7, so I limited the testing scope to versions 3.8 in the django.yml
file:---snip---
strategy:
max-parallel: 4
matrix:
python-version: [3.8, 3.9]
---snip---
README.md
which will show whether your tests are passing: