I am trying to make some tests with my current code but I am struggling with the assertTrue and assertFalse as I cannot pass any test or I get numerous errors during the tests in Python. So basically, most of my functions are something like this:
import pandas as pd
def read_csv_pandas(file_path, column_name):
if not isinstance(column_name, str) & (file_path, str):
return False
else:
start = time.time()
df = pd.read_csv(file_path, ';')
print("Listof values:", df[column_name].tolist())
end = time.time()
n_lines_pandas = df.shape[0]
total_time = end - start
return total_time, n_lines_pandas
This is my test code so far:
class TestIsDottedQad(unittest.TestCase):
def test_read_csv_pandas(self):
self.assertTrue(read_csv_pandas("data/artists_norm.csv", 'name'))
self.assertFalse(read_csv_pandas("data/albums_norm.csv", 235))
How can I set my code to make my test pass?
I tried also to use if not isinstance(column_name, str) & (file_path, str): return value else: ...
but nothing happened.
If there is a simple way to assertTrue/False I would also like to hear about it!
Thank you in advance!