def parse(self, input):
input = input.replace("\n", "").replace(" ", "")
bits = input.split("=>")
return bits[:-1]
Given "a => \nb => \nc=> " the output in the console is ["a", "b", "c"] which is exactly what I want. I guess the console must be formatting the output, but I cannot explain why my tests are failing.
My unit test fails, stating that the result is [["a", "b", "c"]] when I perform assertEqual using unittest.
Can anyone explain? I’m pretty new to Python in the sense I’ve not touched it for a few years, and even then it was pretty limited experience.
Test code
subject = InputParser()
self.assertEqual(subject.parse("a =>\nb => "), ["a", "b"])
Cheers
I just tested this using the module below, and my test passes just fine: