MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / test_str_2_bool

Method test_str_2_bool

tests/utils/misc/test_str2bool.py:21–30  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

19class TestStr2Bool(unittest.TestCase):
20
21 def test_str_2_bool(self):
22 for i in ("yes", "true", "t", "y", "1", True):
23 self.assertTrue(str2bool(i))
24 for i in ("no", "false", "f", "n", "0", False):
25 self.assertFalse(str2bool(i))
26 for bad_value in ("test", 0, 1, 2, None):
27 self.assertFalse(str2bool(bad_value, default=False, raise_exc=False))
28 self.assertTrue(str2bool(bad_value, default=True, raise_exc=False))
29 with self.assertRaises(ValueError):
30 self.assertTrue(str2bool(bad_value))
31
32
33if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

str2boolFunction · 0.90

Tested by

no test coverage detected