Endstand zweiter Praktikumstag: Erstellung des Moduls + Modulverzeichnis; Unittests funktionieren :-)

This commit is contained in:
2018-10-22 16:36:21 +02:00
parent acee1de090
commit ef2c061674
6 changed files with 180 additions and 156 deletions
@@ -1,2 +0,0 @@
import unittest
@@ -8,7 +8,7 @@ def hashMod(bytes):
result += byte
return result % sys.maxsize
if __name__ != "__main__":
if __name__ == "__main__":
myByteArray = bytearray("Schokopraline", encoding='utf-8')
hashvalue = hashMod(myByteArray)
print("Ohne importierten Aufruf lautet der Hashwert zu 'Schokopraline': ", hashvalue)
@@ -0,0 +1,16 @@
from unittest import TestCase
from krypto import hashes
class TestHashMod(TestCase):
def test_hashMod(self):
firstCall = hashes.hashMod("Sahnetorte".encode('utf-8'))
secondCall = hashes.hashMod("Sahnetorte".encode('utf-8'))
straingeCall = hashes.hashMod("Kirschkuchen".encode('utf-8'))
self.assertEqual(firstCall, secondCall, "Die Werte sind gleich! -> Test geglückt") # firstCall and secondCall are Equal so test should finish with OK
self.assertNotEqual(firstCall, straingeCall, "Die Werte sind ungleich, Test ebenfalls geglückt!") # firstCall and straingeCall are not equal so test should finish with OK
#self.assertEqual(firstCall, straingeCall, "Die Werte sind gleich! -> Test geglückt") # firstCall and Strainge call are not equal but equality is tested. Test should finish with FAILED