Skip to content

Commit

Permalink
Update IntegrityError pattern for PostgreSQL 13.
Browse files Browse the repository at this point in the history
A more specific error is raised on higher PostgreSQL versions, for example, as
with the PostgreSQL version running on my local machine. This commit fixes the
error message pattern matching behaviour by adding an optional match to the
detailed error message.
  • Loading branch information
jchristgit committed Jun 4, 2021
1 parent 7d81829 commit 8633eaa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pydis_site/apps/api/tests/test_infractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,10 @@ def test_unique_constraint_accepts_active_infractions_for_different_users(self):
)

def test_integrity_error_if_missing_active_field(self):
pattern = 'null value in column "active" violates not-null constraint'
pattern = (
'null value in column "active" (of relation "api_infraction" )?'
'violates not-null constraint'
)
with self.assertRaisesRegex(IntegrityError, pattern):
Infraction.objects.create(
user=self.user,
Expand Down

0 comments on commit 8633eaa

Please sign in to comment.