KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to write unit tests to ensure correctness of various decorators I've written. Here's the start of the code I'm trying to write: import unittest from memoizer import Memoizer from strategies.mru import MRU @Memoizer(strategy=MRU(maxsize=10)) def fib(x): if x < 2: return 1 else: return fib(x-1) + fib(x-2) class TestMemoizer(unittest.TestCase): def test_simple(self): self.assertEqual(fib(0), 1) self.assertEqual(fib(1), 1) self.assertEqual(fib(10), 89) if __name__ == '__main__': unittest.main() While this works decently for the MRU strategy I have above, I plan to write additional strategies, in which case I'll need to decorate with the fib function in different ways. (Recall that because fib calls fib, setting fib2 = memoize(fib) does not memoize intermediate values so that will not work.) What is the correct way to test the other decorators?
Tags (comma-separated)
Save Edits
Cancel