I have a class that looks like that:
class StoryManager:
STORIES = {1:'stories/itsmyluck.txt', 2:'stories/triptothezoo.txt', 3:'stories/loveatfirstsight.txt'}
def get_fields(self, directory):
self.pattern = re.compile(r'<\s*(.*?)\s*>')
self.results = []
with open(directory, 'r', encoding='utf-8') as f:
text = f.read()
self.matches = self.pattern.finditer(text)
for self.match in self.matches:
self.results.append(self.match[1])
return self.results
and another file that I write tests in:
from app import StoryManager
import unittest
class TestStoryManager(unittest.TestCase):
def test_get_fields(self):
result = ['case1','case2','case3','case4','case5','case6',
'case7','case8','case9','case10','case11','case12']
dirs = ['tests/story1.txt', 'tests/story2.txt', 'tests/story3.txt']
self.assertEqual(StoryManager.get_fields(dirs[0]), result)
if __name__ == '__main__':
unittest.main()
and the problem is that python says :
Traceback (most recent call last):
File "d:\Programowanie ;3\GitRepository\madlibs\test_storymanager.py", line 12, in test_get_fields
self.assertEqual(StoryManager.get_fields(dirs[0]), result)
TypeError: get_fields() missing 1 required positional argument: 'directory'
but as I can see there is argument(that is dirs[0]).
I feel like it is something simple but I can't find out what's wrong. Thanks.