This project has been archived by its maintainers, and is no longer receiving any updates.
interface-mixins
To create an Interface, pass it an interface name and a list of method names. A class will be created which raises NotImplementedError for each of the specified method names:
AnInterface = Interface('AnInterface', [
'some',
'methods',
'the',
'interface',
'should',
'have'
])
To use this interface, simply inherit from it:
class AClass(AnInterface):
pass
We also provide a way to create abstract test cases to help test objects against the interface:
AbstractTestAnInterface = AbstractInterfaceTest('AbstractTestAnInterface', [
'some',
'methods',
'the',
'interface',
'should',
'have'
])
These tests can be used by creating TestCases which inherit from from the abstract test. This makes sure each method is implemented in AClass:
from unittest import TestCase
class TestAClass(AbstractTestAnInterface, TestCase):
def setUp(self):
self.obj = AClass()
It is also possible to create both the Interface and the AbstractInterfaceTest at the same time. Also, you can create multiple interfaces using the following idiom [1]:
interfaces = {
'AnInterface': [
'some',
'methods',
'the',
'interface',
'should',
'have'
],
'AnotherInterface': [
'different',
'methods'
]
}
for interface_name, methods in interfaces.iteritems():
interface_name += 'Interface'
globals()[interface_name] = Interface(interface_name, methods)
test_name = 'AbstractTest' + interface_name
globals()[test_name] = AbstractInterfaceTest(test_name, methods)
Metadata
Release files for interface-mixins 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| interface_mixins-0.0.4.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| interface_mixins-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / interface_mixins-0.0.4.tar.gz
| Download URL | interface_mixins-0.0.4.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50bb34c077ee91c9361169d63ca1791a2b300d5481d13133032e0a7eca37163a
|
|
BLAKE2b-256 checksum How to use checksums |
edcf85a3f7df00e4a4a175cb4478540dfcedb36f6b88c96dde377916c7679a7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / interface_mixins-0.0.4-py3-none-any.whl
| Download URL | interface_mixins-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2301850e8c7e40b11f64fb82d08cd4ab27c2836e92e5bd4f53549a7e23c77b4
|
|
BLAKE2b-256 checksum How to use checksums |
cd800e2a5ba7704f7fef6320b2c1c2199033976941d218d2a1755209d09505b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|