Skip to content

Instantly share code, notes, and snippets.

@ekozlowski
Created February 25, 2016 20:11
Show Gist options
  • Save ekozlowski/a34d18164d55388591a0 to your computer and use it in GitHub Desktop.
Save ekozlowski/a34d18164d55388591a0 to your computer and use it in GitHub Desktop.
class Test_ThisStuff(object):
def setup(self):
print('Setting up')
self.name = 'Ed'
self.age = 38
def teardown(self):
print('tearing down')
self.name = None
self.age = None
def test_name(self):
assert self.name == "Ed"
def test_age(self):
assert self.age == 38
@ekozlowski
Copy link
Author

This is how I use setup and teardown. Running py.test with -s will show you stdout output, and you can see setup and teardown being executed for each test.

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