Pythonのテストの探索でmixinしても大丈夫かどうかを確認してみます。
test_it.py::
from unittest import TestCase
class Mixin(object):
def dummy(self):
pass
class SimpleTest(TestCase, Mixin):
def test_fail(self):
self.fail()
python -m unittest test_it
F
======================================================================
FAIL: test_fail (test_it.SimpleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_it.py", line 11, in test_fail
self.fail()
AssertionError: None
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
make: *** [unittest] Error 1
-> される
pytest
============================================================================================================================= test session starts ==============================================================================================================================
platform darwin -- Python 2.7.12, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: /path/to/test, inifile:
collected 1 items
test_it.py F
=================================================================================================================================== FAILURES ===================================================================================================================================
_____________________________________________________________________________________________________________________________ SimpleTest.test_fail _____________________________________________________________________________________________________________________________
self = <test_it.SimpleTest testMethod=test_fail>
def test_fail(self):
> self.fail()
E AssertionError: None
test_it.py:11: AssertionError
=========================================================================================================================== 1 failed in 0.11 seconds ===========================================================================================================================
make: *** [pytest] Error 1
-> される
nosetests
F
======================================================================
FAIL: test_fail (test_it.SimpleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/path/to/test/test_it.py", line 11, in test_fail
self.fail()
AssertionError: None
----------------------------------------------------------------------
Ran 1 test in 0.061s
FAILED (failures=1)
make: *** [nosetests] Error 1
-> される
- mixinされてても探索される
- そもそも関数名で探索している模様