Skip to content

Instantly share code, notes, and snippets.

@slaykovsky
Created March 8, 2017 15:07
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 slaykovsky/2eeab05c173bd6d5d1092c6a26512625 to your computer and use it in GitHub Desktop.
Save slaykovsky/2eeab05c173bd6d5d1092c6a26512625 to your computer and use it in GitHub Desktop.
from __future__ import print_function
from sys import modules
class Base(object):
test_case = None
@classmethod
def __new__(cls, *args, **kwargs):
cls.test_case = cls.__name__[-4:]
return object.__new__(cls)
class BaseTest(Base):
def test_something(self):
assert self.test_case == self.__class__.__name__[-4:]
meta_class = BaseTest
for i in range(10000):
clazz_name = "Test_{0:04d}".format(i)
clazz = type(clazz_name, (meta_class,), dict())
setattr(modules[meta_class.__module__], clazz.__name__, clazz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment