def login(self, is_valid_username=False, is_valid_password=False, **kwargs):
if is_valid_username:<EOL><INDENT>username = self.VALID_USERNAME<EOL><DEDENT>else:<EOL><INDENT>username = '<STR_LIT>'.join(<EOL>choice(ascii_letters + digits)<EOL>for _ in range(<NUM_LIT:10>)<EOL>)<EOL><DEDENT>if is_valid_password:<EOL><INDENT>password = self.VALID_PASSWORD<EOL><DEDENT>else:<EOL><INDENT>password = self.INVALID_PASSWORD<EOL><DEDENT>post_data = {<EOL>'<STR_LIT:username>': username,<EOL>'<STR_LIT:password>': password,<EOL>**kwargs<EOL>}<EOL>return self.client.post(<EOL>reverse('<STR_LIT>'),<EOL>post_data,<EOL>REMOTE_ADDR=self.ip_address,<EOL>HTTP_USER_AGENT=self.user_agent,<EOL>)<EOL>
Login a user.

A valid credential is used when is_valid_username is True,
otherwise it will use a random string to make a failed login.