コード例 #1
0
ファイル: test_config.py プロジェクト: Qvl22/tsne
    def test_check_boolean(self):
        self.assertEqual(check_boolean(True), True)
        self.assertEqual(check_boolean(False), False)
        self.assertEqual(check_boolean(1), True)
        self.assertEqual(check_boolean(0), False)

        with self.assertRaises(SWATOptionError):
            check_boolean(2)
        with self.assertRaises(SWATOptionError):
            check_boolean('true')
        with self.assertRaises(SWATOptionError):
            check_boolean(1.1)
コード例 #2
0
    def test_check_boolean(self):
        self.assertEqual(check_boolean(True), True)
        self.assertEqual(check_boolean(False), False)
        self.assertEqual(check_boolean(1), True)
        self.assertEqual(check_boolean(0), False)
        self.assertEqual(check_boolean('yes'), True)
        self.assertEqual(check_boolean('no'), False)
        self.assertEqual(check_boolean('T'), True)
        self.assertEqual(check_boolean('F'), False)
        self.assertEqual(check_boolean('true'), True)
        self.assertEqual(check_boolean('false'), False)
        self.assertEqual(check_boolean('on'), True)
        self.assertEqual(check_boolean('off'), False)
        self.assertEqual(check_boolean('enabled'), True)
        self.assertEqual(check_boolean('disabled'), False)

        with self.assertRaises(SWATOptionError):
            check_boolean(2)
        with self.assertRaises(SWATOptionError):
            check_boolean('foo')
        with self.assertRaises(SWATOptionError):
            check_boolean(1.1)