Skip to content

Commit 65987a0

Browse files
committed
📦 Refactor (move) PythonTestMixIn into tests.mixin
1 parent a548330 commit 65987a0

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

testapps/on_device_unit_tests/test_app/main.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,9 @@
44
'require Python 3+').format(sys.version_info.major))
55

66
import unittest
7-
import importlib
87

98
print('Imported unittest')
109

11-
12-
class PythonTestMixIn(object):
13-
14-
module_import = None
15-
16-
def test_import_module(self):
17-
"""Test importing the specified Python module name. This import test
18-
is common to all Python modules, it does not test any further
19-
functionality.
20-
"""
21-
self.assertIsNotNone(
22-
self.module_import,
23-
'module_import is not set (was default None)')
24-
25-
importlib.import_module(self.module_import)
26-
27-
def test_run_module(self):
28-
"""Import the specified module and do something with it as a minimal
29-
check that it actually works.
30-
31-
This test fails by default, it must be overridden by every
32-
child test class.
33-
"""
34-
35-
self.fail('This test must be overridden by {}'.format(self))
36-
37-
print('Defined test case')
38-
39-
import sys
4010
sys.path.append('./')
4111
from tests import test_requirements
4212
suite = unittest.TestLoader().loadTestsFromModule(test_requirements)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import importlib
2+
3+
4+
class PythonTestMixIn(object):
5+
6+
module_import = None
7+
8+
def test_import_module(self):
9+
"""Test importing the specified Python module name. This import test
10+
is common to all Python modules, it does not test any further
11+
functionality.
12+
"""
13+
self.assertIsNotNone(
14+
self.module_import,
15+
'module_import is not set (was default None)')
16+
17+
importlib.import_module(self.module_import)
18+
19+
def test_run_module(self):
20+
"""Import the specified module and do something with it as a minimal
21+
check that it actually works.
22+
23+
This test fails by default, it must be overridden by every
24+
child test class.
25+
"""
26+
27+
self.fail('This test must be overridden by {}'.format(self))
28+
29+
30+
print('Defined test case')

testapps/on_device_unit_tests/test_app/tests/test_requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
from main import PythonTestMixIn
32
from unittest import TestCase
3+
from .mixin import PythonTestMixIn
44

55

66
class NumpyTestCase(PythonTestMixIn, TestCase):

0 commit comments

Comments
 (0)