def test_katakana_list_from(self): data = [ # (val, expect) (True, 'あいうエお', ['エ']), ] validate_with_fail( self, 'katakana_list_from', lambda v, expect: self.assertEqual( ustr.katakana_list_from(v), expect), data)
def test_list_without_none(self): data = [ # (val, expect) (True, [1, 2, 3, None, 5], [1, 2, 3, 5]), ] validate_with_fail( self, 'list_without_none', lambda val, expect: self.assertEqual( utl.list_without_none(val), expect), data)
def test_hiragana_list_from(self): data = [ # (val, expect) (True, 'あい123', ['あ', 'い']), ] validate_with_fail( self, 'hiragana_list_from', lambda v, expect: self.assertEqual( ustr.hiragana_list_from(v), expect), data)
def test_safe_divided(self): data = [ # (valA, valB, expect) (True, 4, 2, 2), (True, 5, 0, 0), ] validate_with_fail( self, 'safe_divided', lambda v0, v1, expect: self.assertEqual( umath.safe_divided(v0, v1), expect), data)
def test_int_ceil(self): data = [ # (valA, valB, expect) (True, 4, 2, 2), (True, 5, 2, 3), ] validate_with_fail( self, "int_ceil", lambda v0, v1, expect: self.assertEqual( umath.int_ceil(v0, v1), expect), data)
def test_name_set_from(self): data = [ # (base, name, expect) (True, '田中,太郎', '太郎', ('太郎','田中', '田中太郎', '太郎・田中')), ] validate_with_fail(self, 'name_set_from', lambda base, name, expect: self.assertEqual( uname.name_set_from(base, name), expect), data)
def test_dict_from_string(self): data = [ # (val, splitter, expect) (True, "a:test", ":", { "a": "test" }), ] validate_with_fail( self, "dict_from_string", lambda v, splt, expect: self.assertEqual( ustr.dict_from_string(v, splt), expect), data)
def test_string_replaced_by_tag(self): data = [ # (val, tags, prefix, expect) (True, '$test apple', { 'test': 'AN' }, '$', 'AN apple'), ] validate_with_fail( self, 'string_replaced_by_tag', lambda v, tags, prefix, expect: self.assertEqual( ustr.string_replaced_by_tag(v, tags, prefix), expect), data)
def test_instance(self): data = [ # (name, sh, fh) (True, "test", "%(message)", "%(message)"), ] def checker(name, sh, fh): _ = logger.MyLogger(name, sh, fh) self.assertIsInstance(_, logger.MyLogger) self.assertEqual(_.name, name) validate_with_fail(self, 'class-instance', checker, data)
def test_calling_dict_from(self): data = [ # (calling, name, expect) (True, "A:test", "taro", { "A": "test", "S": "taro", "M": "私" }), ] validate_with_fail( self, 'calling_dict_from', lambda calling, name, expect: self.assertEqual( udict.calling_dict_from(calling, name), expect), data)
def test_static_get_logger(self): data = [ # (name, sh, fh) (True, "test", '%(message)', '%(message)'), ] def checker(name, sh, fh): _ = logger.MyLogger.get_logger(name, sh, fh) self.assertIsInstance(_, logger.MyLogger) self.assertEqual(_.name, name) _ validate_with_fail(self, 'staticmethod-get_logger', checker, data)
def test_validate_string_duplicate_chopped(self): data = [ # (val, expect) (True, '太郎。。', '太郎。'), (True, '太郎、、', '太郎、'), (True, '太郎。、', '太郎。'), (True, '太郎、。', '太郎、'), (True, '?、', '? '), (True, '!。', '! '), (True, '?。', '? '), ] validate_with_fail( self, 'validate_string_duplicate_chopped', lambda v, expect: self.assertEqual( ustr.validate_string_duplicate_chopped(v), expect), data)
def test_combine_dict(self): data = [ # (dictA, dictB, expect) (True, { 'a': 'apple' }, { 'b': 'ball' }, { 'a': 'apple', 'b': 'ball' }), ] validate_with_fail( self, "combine_dict", lambda v0, v1, expect: self.assertEqual( udict.combine_dict(v0, v1), expect), data)
def test_dict_sorted(self): data = [ # (dict, is_reverse, expect) (True, { 'b': 'ball', 'a': 'apple', 'c': 'can' }, False, { 'a': 'apple', 'b': 'ball', 'c': 'can' }), ] validate_with_fail( self, 'dict_sorted', lambda v, is_rev, expect: self.assertEqual( udict.dict_sorted(v, is_rev), expect), data)