Skip to content

Instantly share code, notes, and snippets.

@markpasc
Created November 10, 2011 19:13
Show Gist options
  • Save markpasc/1355822 to your computer and use it in GitHub Desktop.
Save markpasc/1355822 to your computer and use it in GitHub Desktop.
python test chunking
from unittest import TestCase
class TestThing(TestCase):
def setUp(self):
self.thing = do_a_thing()
def test_foo(self):
self.assertEqual(self.thing.foo, 'bar')
def test_baz(self):
self.assertEqual(self.thing.baz, 'quux')
def test_arf(self):
self.assertEqual(self.thing.arf, 'moo')
# which is why the *class* is called "TestCase"
# other tests in other TestCases
from unittest import TestCase
class TestSomething(TestCase):
def test_thing(self):
thing = do_a_thing()
self.assertEqual(thing.foo, 'bar')
self.assertEqual(thing.baz, 'quux')
self.assertEqual(thing.arf, 'moo')
# other tests in other test_* methods
@sivy
Copy link

sivy commented Nov 10, 2011

Ok, so my "what i write in practice" is not uncommon. :-)

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