Skip to content

Instantly share code, notes, and snippets.

@dmerejkowsky
Last active January 27, 2016 13:45
Show Gist options
  • Save dmerejkowsky/8343144c51bb8d98202d to your computer and use it in GitHub Desktop.
Save dmerejkowsky/8343144c51bb8d98202d to your computer and use it in GitHub Desktop.
unittest sucks
# in test_qibuild_configure.py
class QiBuildTestCase(unittest.TestCase, ActionTestCase):
def setUp(self):
self.tmpdir = tmpfile.mkdtemp("test-qibuild-")
def test_configure(self):
# do stuff in tmpdir
rc = ...
self.assertEquals(rc, 0)
def tearDown(self):
shutil.rmtree(self.tmpdir)
# in run_tests.py
suite = unittest.TestSuite()
for test_case in TEST_CASES:
suite.addTests(unittest.makeSuite(test_case))
runner = unittest.TextTestRunner()
result = runner.run(suite)
if not result.wasSuccessful():
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment