Language: Python
Label: safe
CWE: CWE-521 \u2014 Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.

Code:
    def test_register_user_already_registered(self):
        User.objects.create_user("kiwi-tester", "new-tester@example.com", "password")

        response = self.client.post(
            self.register_url,
            {
                "username": "test_user",
                "password1": __FOR_TESTING__,
                "password2": __FOR_TESTING__,
                "email": "new-tester@example.com",
            },
            follow=False,
        )
        self.assertContains(response, _("A user with that email already exists."))

        user = User.objects.filter(username="test_user")
        self.assertEqual(user.count(), 0)