diff --git a/src/tests/test_shamira.py b/src/tests/test_shamira.py --- a/src/tests/test_shamira.py +++ b/src/tests/test_shamira.py @@ -3,7 +3,7 @@ import random from unittest import TestCase -from shamira import _shareByte +from shamira import _share_byte from shamira import * @@ -19,28 +19,28 @@ class TestShamira(TestCase): def tearDownClass(cls): os.urandom = cls._urandom - def test_shareByte(self): + def test_share_byte(self): with self.assertRaises(InvalidParams): # too few shares - _shareByte(b"a", 5, 4) + _share_byte(b"a", 5, 4) with self.assertRaises(InvalidParams): # too many shares - _shareByte(b"a", 5, 255) + _share_byte(b"a", 5, 255) with self.assertRaises(ValueError): # not castable to int - _shareByte("x", 2, 3) + _share_byte("x", 2, 3) - vals = _shareByte(ord(b"a"), 2, 3) + vals = _share_byte(ord(b"a"), 2, 3) points = list(zip(range(1, 256), vals)) - self.assertEqual(gf256.getConstantCoef(*points), ord(b"a")) - self.assertEqual(gf256.getConstantCoef(*points[:2]), ord(b"a")) - self.assertNotEqual(gf256.getConstantCoef(*points[:1]), ord(b"a")) # underdetermined => random + self.assertEqual(gf256.get_constant_coef(*points), ord(b"a")) + self.assertEqual(gf256.get_constant_coef(*points[:2]), ord(b"a")) + self.assertNotEqual(gf256.get_constant_coef(*points[:1]), ord(b"a")) # underdetermined => random - def testGenerateReconstructRaw(self): + def test_generate_reconstruct_raw(self): for (k, n) in [(2, 3), (254, 254)]: - shares = generateRaw(b"abcd", k, n) + shares = generate_raw(b"abcd", k, n) random.shuffle(shares) - self.assertEqual(reconstructRaw(*shares[:k]), b"abcd") - self.assertNotEqual(reconstructRaw(*shares[:k-1]), b"abcd") + self.assertEqual(reconstruct_raw(*shares[:k]), b"abcd") + self.assertNotEqual(reconstruct_raw(*shares[:k-1]), b"abcd") - def testGenerateReconstruct(self): + def test_generate_reconstruct(self): for encoding in ["hex", "b32", "b64"]: for secret in [b"abcd", "abcde", "ěščřžý"]: for (k, n) in [(2, 3), (254, 254)]: @@ -56,13 +56,13 @@ class TestShamira(TestCase): with self.assertRaises(DecodingException): reconstruct(*shares) - def testEncode(self): + def test_encode(self): share = (2, b"\x00\x01\x02") - for (encoding, encodedStr) in [("hex", '000102'), ("b32", 'AAAQE==='), ("b64", 'AAEC')]: + for (encoding, encoded_str) in [("hex", '000102'), ("b32", 'AAAQE==='), ("b64", 'AAEC')]: with self.subTest(enc=encoding): - self.assertEqual(encode(share, encoding), "2."+encodedStr) + self.assertEqual(encode(share, encoding), "2."+encoded_str) - def testDecode(self): + def test_decode(self): with self.assertRaises(MalformedShare): decode("AAA") decode("1.") @@ -95,8 +95,8 @@ class TestShamira(TestCase): ]: with self.subTest(shares=shares): with self.assertRaises(DetectionException): - detectEncoding(shares) - self.assertEqual(detectEncoding(["10.00010203"]), "hex") - self.assertEqual(detectEncoding(["2.AAAQEAY="]), "b32") - self.assertEqual(detectEncoding(["3.AAECAw=="]), "b64") - self.assertEqual(detectEncoding(["3.AAECAwQF", "1.00010203"]), "b64") + detect_encoding(shares) + self.assertEqual(detect_encoding(["10.00010203"]), "hex") + self.assertEqual(detect_encoding(["2.AAAQEAY="]), "b32") + self.assertEqual(detect_encoding(["3.AAECAw=="]), "b64") + self.assertEqual(detect_encoding(["3.AAECAwQF", "1.00010203"]), "b64")