Python'da Teste Giriş
Alexander Levin
Data Scientist
.setUp(): testten önce fikstürü hazırlamak için çağrılır.tearDown(): testten sonra ortamı temizlemek için çağrılırimport unittest
class TestLi(unittest.TestCase):
# Fixture setup method
def setUp(self):
self.li = [i for i in range(100)]
# Fixture teardown method
def tearDown(self):
self.li.clear()
# Test method
def test_your_list(self):
self.assertIn(99, self.li)
self.assertNotIn(100, self.li)
Doğru sözdizimi: setUp (U büyük) ve tearDown (D büyük).
class TestLi(unittest.TestCase):
# Fixture setup method
def setUp(self):
self.li = [i for i in range(100)]
# Fixture teardown method
def tearDown(self):
self.li.clear()
Komut: python3 -m unittest test_in_list.py
.setUp() ve .tearDown() ile bir çalıştırmanın çıktısı:

.set_up() ile bir çalıştırmanın çıktısı:

.setUp() yöntemini yazın.tearDown() yöntemini yazın.setUp(): testten önce fikstürü hazırlamak için çağrılır..tearDown(): testten sonra ortamı temizlemek için çağrılır.Python'da Teste Giriş