def test_error_condition_cmd(): cmd = ["simply", "delete"] assert ("Error" in (tr.main(cmd, "aaabbbccdef", 'a-c'))) cmd = ["simply"] assert ("Error" in (tr.main(cmd, "aaabbbccdef", 'a-c', 'A-Z'))) cmd = ["delete"] assert ("Error" in (tr.main(cmd, "aaabbbccdef", 'a-c', 'A-Z')))
def test_tr_basic(): results = tr.main(['t', 'X'], 'ttyyhhxxaa') assert results == "XXyyhhxxaa" results = tr.main(['XX', 'tt'], results) assert results == 'ttyyhhxxaa' results = tr.main(['hh', 'XX'], results) assert results == 'ttyyXXxxaa' results = tr.main(['hh', 'XX'], '') assert results == ''
def test_translate(): cmd = [] # Nothing assert (tr.main(cmd, "ABC", 'A-Z') == None) # Error Condition : SET2 is empty assert (tr.main(cmd, "ABC", 'A-Z', 'a-c') == None) #catch error, because its len is different assert (tr.main(cmd, "ABCDZZZ", 'A-Z', 'a-z') == 'abcdzzz') assert (tr.main(cmd, "abcdzzz", 'a-z', 'A-Z') == 'ABCDZZZ') assert (tr.main(cmd, "abcdzzzABCDZZZ", 'a-z', 'A-Z') == 'ABCDZZZABCDZZZ') assert (tr.main(cmd, "abcdzzzABCDZZZ", 'A-Z', 'a-z') == 'abcdzzzabcdzzz') assert (tr.main(cmd, "My\nUID is\n1004", '\n', ' ') == 'My UID is 1004') assert (tr.main(cmd, "My UID is 1004", ' ', ':') == 'My:UID:is:1004')
def test_simply(): cmd = ["simply"] assert (tr.main(cmd, "aaaa", 'a') == 'a') assert (tr.main(cmd, "aaaabbbcccd", 'a-z') == "abcd") assert (tr.main(cmd, "AAABBBCC", 'a-z') == "AAABBBCC") assert (tr.main(cmd, "aaabbbccAAABBBCC", 'A-Z') == "aaabbbccABC") assert (tr.main(cmd, "aaabbbccAAABBBCC", 'a-z') == "abcAAABBBCC") assert (tr.main(cmd, "Hi, is there any things?", ' ') == "Hi, is there any things?")
def test_tr_cs(): results = tr.main(['-cs', 't', 'X'], 'ttyyhhxxaa') assert results == "XXyyhhxxaa"
def test_tr_d(): results = tr.main(['-d', 't'], 'ttyyhhxxaa') assert results == "yyhhxxaa"
def test_delete(): cmd = ['delete'] assert (tr.main(cmd, "aaaab", 'a') == 'b') assert (tr.main(cmd, "aaabbbccdef", 'a-c') == 'def') assert (tr.main(cmd, "aaabbbccdeffgg", 'c-z') == 'aaabbb')
def test_main(): cmd = ["simply"] tr.main(cmd, "abc", 'a')
def test_tr_truncate(): results = tr.main(['-t', 'httttt', 'Xx'], 'httttttaaaaa') assert results == 'Xxtttttaaaaa'
def test_main(): result = tr.main(['arg1', 'arg2', 'argv3']) print(f">>> result is {result}.")