def test_failOnKeyError(self):
        """
        If the getpwnam function raises a KeyError, the login fails with an
        L{UnauthorizedLogin} exception.
        """
        def getpwnam(username):
            raise KeyError(username)
        checker = checkers.UNIXPasswordDatabase([getpwnam])
        credential = UsernamePassword(b'username', b'username')
        self.assertUnauthorizedLogin(checker.requestAvatarId(credential))

        If the getpwnam function raises a KeyError, the login fails with an
        L{UnauthorizedLogin} exception.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_checkers.py