나는 단위 테스트를 처음 사용했습니다. 필자가 작성한 웹 스크레이퍼에 대한 단위 테스트를 작성하고 싶습니다. 내 스크레이퍼는 다른 날짜를 입력하면 결과가 다른 로컬 디스크의 웹 사이트에서 데이터를 수집합니다.unittest web scraper in python
스크립트에 다음과 같은 기능이 있습니다.
get_date [returns date mentioned on web page]
get_product_and_cost [returns product mentioned and their cost]
내가 지금까지 내가 보통이
class SimplisticTest(unittest.TestCase):
def setUp(self):
data = read_file("path to file")
self.soup = BeautifulSoup(data,'html5lib')
def test_date(self):
self.assertIsInstance(get_date(self.soup), str)
def test_date_length(self):
self.assertEqual(len(get_date(self.soup)),10)
if __name__ == '__main__':
unittest.main()