コード例 #1
0
 def test_decrypt_chr3(self):
     """key=3で復号化する"""
     cci = CaesarCipher("abc", key=3)
     crypted_txt = cci.encrypt()
     plain_text = cci.decrypt(crypted_txt)
     assert crypted_txt == "def"
     assert plain_text == "abc"
コード例 #2
0
 def test_decrypt_chr25(self):
     """key=25で復号化する"""
     cci = CaesarCipher("abc", key=25)
     crypted_txt = cci.encrypt()
     plain_text = cci.decrypt(crypted_txt)
     assert crypted_txt == "zab"
     assert plain_text == "abc"
コード例 #3
0
def test_isinstance():
    cci = CaesarCipher("aaa")

    assert isinstance(cci, CaesarCipher)
コード例 #4
0
    def test_encrypt_chr100000(self):
        """平文をものすごく大きい数ずらす"""
        cci = CaesarCipher("abc", key=100000)
        expected = "efg"

        assert cci.encrypt() == expected
コード例 #5
0
    def test_encrypt_chr26(self):
        """平文を26文字ずらすテスト"""
        cci = CaesarCipher("abc", key=26)
        expected = "abc"

        assert cci.encrypt() == expected
コード例 #6
0
    def test_encrypt_chr25(self):
        """平文を25文字ずらすテスト"""
        cci = CaesarCipher("abc", key=25)
        expected = "zab"

        assert cci.encrypt() == expected
コード例 #7
0
    def test_encrypt_chr24(self):
        """平文を24文字ずらすテスト"""
        cci = CaesarCipher("abc", key=24)
        expected = "yza"

        assert cci.encrypt() == expected
コード例 #8
0
    def test_encrypt_chr3(self):
        """平文を3文字ずらすテスト"""
        cci = CaesarCipher("abc")

        expected = "def"
        assert cci.encrypt() == expected
コード例 #9
0
def test_check_no_input(capsys):
    with pytest.raises(SystemExit) as excinfo:
        cci = CaesarCipher("")
    out, _ = capsys.readouterr()

    assert out == "入力エラー。英字小文字a-zを入力してください\n"