Skip to content

Instantly share code, notes, and snippets.

@vane
Created July 6, 2018 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vane/b4c6355a1044a9f4b51ba17297d0f29f to your computer and use it in GitHub Desktop.
Save vane/b4c6355a1044a9f4b51ba17297d0f29f to your computer and use it in GitHub Desktop.
Python dirty way to run unit tests in order
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import unittest
def make_suite():
class Test(unittest.TestCase):
def test_32(self):
print "32"
def test_23(self):
print "23"
suite = unittest.TestSuite()
suite.addTest(Test('test_32'))
suite.addTest(Test('test_23'))
return suite
suite = make_suite()
class T(unittest.TestCase):
counter = 0
def __call__(self, *args, **kwargs):
res = suite._tests[T.counter](*args, **kwargs)
T.counter += 1
return res
for t in suite._tests:
name = "{}${}".format(t._testMethodName, t.__class__.__name__)
setattr(T, name, t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment