my_unitest folder in sys.path,structured as
packages.
Use
pytest
my_uintest/
folder_a/
|-- __init__.py
|-- file_a.py
folder_b/
|-- __init__.py
|-- file_b.py
file_a.py:
import unittest
class A(unittest.TestCase):
def testA(self):
self.assertEqual(42, 43)
file_b.py:
import unittest
from my_uintest.folder_a import file_a
class B(unittest.TestCase):
def testA(self):
file_a.A.testA(self)
if __name__ == '__main__':
unittest.main()
Test:
Output:
λ python file_b.py
F
======================================================================
FAIL: testA (__main__.B)
----------------------------------------------------------------------
Traceback (most recent call last):
File "file_b.py", line 6, in testA
file_a.A.testA(self)
File "C:\Python36\my_uintest\folder_a\file_a.py", line 5, in testA
self.assertEqual(42, 43)
AssertionError: 42 != 43
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (failures=1)