def test_badUsernamePasswordLogin(self):
        """
        Test that a login attempt with an invalid user or invalid password
        fails in the appropriate way.
        """
        self.portal.registerChecker(
            checkers.InMemoryUsernamePasswordDatabaseDontUse(user=b'pass'))

        firstLogin = self.clientFactory.login(
            credentials.UsernamePassword(b'nosuchuser', b'pass'))
        secondLogin = self.clientFactory.login(
            credentials.UsernamePassword(b'user', b'wrongpass'))

        self.assertFailure(firstLogin, UnauthorizedLogin)
        self.assertFailure(secondLogin, UnauthorizedLogin)
        d = gatherResults([firstLogin, secondLogin])

        def cleanup(ignore):
            errors = self.flushLoggedErrors(UnauthorizedLogin)
            self.assertEqual(len(errors), 2)
        d.addCallback(cleanup)

        self.establishClientAndServer()
        self.pump.flush()

        return d

        Test that a login attempt with an invalid user or invalid password
        fails in the appropriate way.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/spread/test/test_pb.py