I am trying to start code using a test-driven approach. I have in English what I want my code to do and I am starting off with writing some unit tests. Below is my current code for my unit test:
import unittest
class Testing_Tuple(unittest.TestCase):
def test_tuple(self):
Input = Testing_Tuple(True)
self.assertEqual(type(Input[0]), str)
self.assertEqual(type(Input[1]), str,
self.assertEqual(type(Input[2]), int," Testing to make sure a tuple is returned")
I would like to create a class called car. The input to class car
should be a single tuple that contains three elements: two strings and one integer. The first string will be the brand of the car (e.g. "Honda"
, "Ford"
), the second string will be the make of the car (e.g. "corolla"
, "mustang"
), and the integer will represent the miles per gallon the car gets.
Basically I want to above unit test to check if the input is a tuple by testing if element one is a string, element one is a string and element three is an integer. I am not receiving any errors with the current code but I just want to make sure that my logic is correct.