I am trying to write unit tests for my search function which searches through a directory and returns a list of matching files which matches the query. While writing unit tests I realized that if I give it test data, the test data might just take up too much space. How can i get over this problem ? I thought of mocking test data but I am not familiar on how to do this. This is currently how one of my unit tests looks like
import search_function
import unittest
class searchDirTest(unittest.TestCase):
def setUp(self):
pass
def test_file_name_case_sensitive(self):
res = search_function.search_function('./testData', 'allsmall')
self.assertEquals(res, ['./testData/allsmall.txt', './testData/testData_subdir/allsmall.txt'])
self.assertNotEquals(res, ['./testData/ALLSMALL.txt'])
if __name__ == "__main__":
unittest.main()
Also the search_function takes 2 arguments. The Path and the search query. Any pointers on how to achieve this ?