Created
July 6, 2018 18:09
-
-
Save vane/b4c6355a1044a9f4b51ba17297d0f29f to your computer and use it in GitHub Desktop.
Python dirty way to run unit tests in order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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