import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
# Запустит все тесты
python3 manage.py test
# Запустит только тесты в приложении application
python3 manage.py test application
# Запустит только тесты из файла test_urls.py в приложении application
python3 manage.py test application.tests.test_urls
# Запустит только тесты из класса StaticURLTests для test_urls.py в приложении application
python3 manage.py test application.tests.test_urls.StaticURLTests
# Запустит только тест test_index()
# из класса StaticURLTests для test_urls.py в приложении application
python3 manage.py test application.tests.test_urls.StaticURLTests.test_index