Skip to content

Commit f25af5e

Browse files
authored
Changed test_get_hash() and removed the "import hashlib"
1 parent d227e2c commit f25af5e

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

usefulib/tests.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111
import unittest
12-
import hashlib
12+
import _usefulibs
1313
from _usefulibs import *
1414

1515
class TestUsefulibs(unittest.TestCase):
@@ -76,17 +76,16 @@ def test_external_verbose_output(self):
7676
self.assertEqual(f.read(), "# Logged by usefulibs.external_verbose_output()\n\nTest Data\n1 2 3\na b c")
7777
def test_get_hash(self):
7878
""" @MKM12345 """
79-
string1 = "Hello, world!"
80-
expected_hash1 = hashlib.sha256(string1.encode('utf-8')).hexdigest()
81-
self.assertEqual(get_hash(string1), expected_hash1)
79+
input_password = "password123"
80+
stored_hash = _usefulibs.get_hash(input_password)
8281

83-
string2 = ""
84-
expected_hash2 = hashlib.sha256(string2.encode('utf-8')).hexdigest()
85-
self.assertEqual(get_hash(string2), expected_hash2)
82+
user_input = input("Enter a password: ")
83+
hashed_input = _usefulibs.get_hash(user_input)
8684

87-
string3 = "This is a longer string that I am using to test the get_hash function. It should produce the same hash every time it is called with this input."
88-
expected_hash3 = hashlib.sha256(string3.encode('utf-8')).hexdigest()
89-
self.assertEqual(get_hash(string3), expected_hash3)
85+
if hashed_input == stored_hash:
86+
print("Correct")
87+
else:
88+
print("Wrong")
9089

9190

9291
if __name__ == "__main__":

0 commit comments

Comments
 (0)