Skip to content

Instantly share code, notes, and snippets.

@MarkBennett
Created December 9, 2011 22:56
Show Gist options
  • Save MarkBennett/1453692 to your computer and use it in GitHub Desktop.
Save MarkBennett/1453692 to your computer and use it in GitHub Desktop.
Python functional programming
import unittest
class MyTestCase(unittest.TestCase):
@classmethod
def make_an_example_of(cls, example_name, example):
def example_test_template(self):
self.assertEqual(stuff, example)
setattr(cls, "test_an_example_of_%s" %(example_name), example_test_template)
MyTestCase.make_an_example_of("Bob")
MyTestCase.make_an_example_of("Frank")
@MarkBennett
Copy link
Author

Obviously, you would provide a more comprehensive example with input and output params for each example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment