Answer the question
In order to leave comments, you need to log in
unittest in python
there is a function:
def is_car_exist(make, model):
url = f'https://vpic.nhtsa.dot.gov/api/vehicles/GetModelsForMake/\
{make.capitalize()}?format=json'
data = requests.get(url).json()['Results']
return any(model.capitalize() == car['Model_Name'] for car in data)
class TestCar(unittest.TestCase):
def test_is_car_exist(self):
self.assertTrue(car.is_car_exist('honda', 'civic'))
self.assertFalse(car.is_car_exist('Mars', 'merana'))
Answer the question
In order to leave comments, you need to log in
The above code is the unit test.
A unit test verifies that a particular module (class, function, etc.) implements the expected behavior, both externally observable and internally implemented. In other words, it checks that the module conforms to the expected interface.
An integration test checks the ability of different modules to interact within the intended framework, i.e. checks the design of the interaction interface itself. Are there enough opportunities for interaction? Have we forgotten some method?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question