-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
test.py
40 lines (34 loc) · 1.03 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import importlib
import os
import sys
import unittest
PACKAGE_MAP = {
"3.9": "certifi",
"3.10": "pytz",
"3.11": "setuptools",
"3.12": "six",
"3.13": "urllib3",
}
class TestActionSuite(unittest.TestCase):
def test_check_python_version(self):
self.assertEqual(
".".join(map(str, sys.version_info[:2])),
".".join(os.getenv("PYTHON_VERSION").split(".")[:2]),
)
def test_check_dependencies(self):
python_version = ".".join(map(str, sys.version_info[:2]))
for package in PACKAGE_MAP.values():
if package != PACKAGE_MAP[python_version]:
try:
print(importlib.import_module(package))
except ImportError:
pass
self.assertRaises(
ModuleNotFoundError,
importlib.import_module,
package,
)
else:
importlib.import_module(package)
if __name__ == "__main__":
unittest.main()