Make a subclass of the abstract class, then test the subclass.
from abc import ABCMeta, abstractmethod
class ThisIsAnAbstractClass(object):
__metaclass__ = ABCMeta # <--
@abstractmethod
def __init__(self, parameter):
self.parameter = parameter
def do_something():
"""do something"""
class ConcreteClass(ThisIsAnAbstractClass):
def __init__(self, parameter):
super(ConcreteClass, self).__init__(parameter)
try:
ThisIsAnAbstractClass('test')
assert False, 'Abstract class instance created!'
except TypeError:
pass
assert ConcreteClass('test').parameter == 'test'
NOTE: You should use abc.ABCMeta
as a metaclass.