mirror of
https://github.com/TeamPGM/tgcrypto.git
synced 2024-11-22 07:27:39 +00:00
Fix TypeError tests for Python 3.4
This commit is contained in:
parent
aabb77de64
commit
0fe11896d9
@ -133,12 +133,14 @@ class TestCBC256Cryptography(unittest.TestCase):
|
||||
|
||||
|
||||
class TestCBC256Input(unittest.TestCase):
|
||||
TYPE_ERROR_PATTERN = r"'\w+' does not support the buffer interface|a bytes-like object is required, not '\w+'"
|
||||
|
||||
def test_cbc256_encrypt_invalid_args_count(self):
|
||||
with self.assertRaisesRegex(TypeError, r"function takes exactly \d arguments \(\d given\)"):
|
||||
tgcrypto.cbc256_encrypt(os.urandom(16), os.urandom(32))
|
||||
|
||||
def test_cbc256_encrypt_invalid_args_type(self):
|
||||
with self.assertRaisesRegex(TypeError, r"a bytes-like object is required, not '\w+'"):
|
||||
with self.assertRaisesRegex(TypeError, self.TYPE_ERROR_PATTERN):
|
||||
tgcrypto.cbc256_encrypt(1, 2, 3)
|
||||
|
||||
def test_cbc256_encrypt_empty_data(self):
|
||||
@ -158,7 +160,7 @@ class TestCBC256Input(unittest.TestCase):
|
||||
tgcrypto.cbc256_decrypt(os.urandom(16), os.urandom(32))
|
||||
|
||||
def test_cbc256_decrypt_invalid_args_type(self):
|
||||
with self.assertRaisesRegex(TypeError, r"a bytes-like object is required, not '\w+'"):
|
||||
with self.assertRaisesRegex(TypeError, self.TYPE_ERROR_PATTERN):
|
||||
tgcrypto.cbc256_decrypt(1, 2, 3)
|
||||
|
||||
def test_cbc256_decrypt_empty_data(self):
|
||||
|
@ -108,12 +108,14 @@ class TestCTR256Cryptography(unittest.TestCase):
|
||||
|
||||
|
||||
class TestCTR256Input(unittest.TestCase):
|
||||
TYPE_ERROR_PATTERN = r"'\w+' does not support the buffer interface|a bytes-like object is required, not '\w+'"
|
||||
|
||||
def test_ctr256_encrypt_invalid_args_count(self):
|
||||
with self.assertRaisesRegex(TypeError, r"function takes exactly \d arguments \(\d given\)"):
|
||||
tgcrypto.ctr256_encrypt(os.urandom(8), os.urandom(32), os.urandom(16))
|
||||
|
||||
def test_ctr256_encrypt_invalid_args_type(self):
|
||||
with self.assertRaisesRegex(TypeError, r"a bytes-like object is required, not '\w+'"):
|
||||
with self.assertRaisesRegex(TypeError, self.TYPE_ERROR_PATTERN):
|
||||
tgcrypto.ctr256_encrypt(1, 2, 3, 4)
|
||||
|
||||
def test_ctr256_encrypt_empty_data(self):
|
||||
@ -141,7 +143,7 @@ class TestCTR256Input(unittest.TestCase):
|
||||
tgcrypto.ctr256_decrypt(os.urandom(8), os.urandom(32), os.urandom(16))
|
||||
|
||||
def test_ctr256_decrypt_invalid_args_type(self):
|
||||
with self.assertRaisesRegex(TypeError, r"a bytes-like object is required, not '\w+'"):
|
||||
with self.assertRaisesRegex(TypeError, self.TYPE_ERROR_PATTERN):
|
||||
tgcrypto.ctr256_decrypt(1, 2, 3, 4)
|
||||
|
||||
def test_ctr256_decrypt_empty_data(self):
|
||||
|
@ -24,12 +24,14 @@ import tgcrypto
|
||||
|
||||
|
||||
class TestIGE256Input(unittest.TestCase):
|
||||
TYPE_ERROR_PATTERN = r"'\w+' does not support the buffer interface|a bytes-like object is required, not '\w+'"
|
||||
|
||||
def test_ige256_encrypt_invalid_args_count(self):
|
||||
with self.assertRaisesRegex(TypeError, r"function takes exactly \d arguments \(\d given\)"):
|
||||
tgcrypto.ige256_encrypt(os.urandom(16), os.urandom(32))
|
||||
|
||||
def test_ige256_encrypt_invalid_args_type(self):
|
||||
with self.assertRaisesRegex(TypeError, r"a bytes-like object is required, not '\w+'"):
|
||||
with self.assertRaisesRegex(TypeError, self.TYPE_ERROR_PATTERN):
|
||||
tgcrypto.ige256_encrypt(1, 2, 3)
|
||||
|
||||
def test_ige256_encrypt_empty_data(self):
|
||||
@ -49,7 +51,7 @@ class TestIGE256Input(unittest.TestCase):
|
||||
tgcrypto.ige256_decrypt(os.urandom(16), os.urandom(32))
|
||||
|
||||
def test_ige256_decrypt_invalid_args_type(self):
|
||||
with self.assertRaisesRegex(TypeError, r"a bytes-like object is required, not '\w+'"):
|
||||
with self.assertRaisesRegex(TypeError, self.TYPE_ERROR_PATTERN):
|
||||
tgcrypto.ige256_decrypt(1, 2, 3)
|
||||
|
||||
def test_ige256_decrypt_empty_data(self):
|
||||
|
Loading…
Reference in New Issue
Block a user