forked from facebookincubator/ft_utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_compat.py
30 lines (23 loc) · 857 Bytes
/
test_compat.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
# Copyright (c) Meta Platforms, Inc. and affiliates.
import unittest
try:
import ft_utils._test_compat as _test_compat
except ImportError:
# @manual
import ft_utils.tests._test_compat as _test_compat # pyre-ignore
class TestCompat(unittest.TestCase):
def test_atomics(self):
test_cls = _test_compat.TestCompat
methods = [name for name in dir(test_cls) if callable(getattr(test_cls, name))]
test_obj = test_cls()
errs = []
for method_name in methods:
if str(method_name).startswith("test_"):
try:
method = getattr(test_cls, method_name)
method(test_obj)
except AssertionError as e:
errs.append(e)
self.assertEqual(errs, [], str(errs))
if __name__ == "__main__":
unittest.main()