Python Unittest: Error False is not true. Matching encrypted password with normal password. Crypt

  boolean, crypt, passwords, python, unit-testing

I’m making a "password checker" which matches a password with an encrypted password out of a random passwords list (these passwords are not real).
It has to pass a unittest created by my teacher.

def checkPassword(pswd, cpswd):

hallo = crypt.crypt(pswd, salt=cpswd)
if hallo == cpswd:
    return True
else:
    return False

This is the part of the unittest which raises an error.

    def test_empty(self):
  
    self.assertTrue(opg_rh.checkPassword('', ''))
    self.assertTrue(opg_rh.checkPassword('', 'zqN6spSQhii2U'))

    def test_pdf_1(self):
    
    self.assertTrue(opg_rh.checkPassword('test', 'npDnXtpN5py4U'))
    self.assertFalse(opg_rh.checkPassword('test', '2Y8H2JzGziJ0M'))

The error I get =
def test_empty(self):
self.assertTrue(opg_rh.checkPassword(”, ”))
AssertionError: False is not true

Does anyone know what’s wrong in my code? I just can’t figure it out

Source: Python Questions

LEAVE A COMMENT