From 660795fbbd280533d5772ae058ba2df2cb8501fd Mon Sep 17 00:00:00 2001 From: Emily Przykucki Date: Mon, 2 Dec 2024 15:29:30 -0500 Subject: [PATCH] Using `re.escape()` in regexs --- .../tests/utils/test_random_distribution_sampler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flepimop/gempyor_pkg/tests/utils/test_random_distribution_sampler.py b/flepimop/gempyor_pkg/tests/utils/test_random_distribution_sampler.py index 0d94c0456..0dcd110fb 100644 --- a/flepimop/gempyor_pkg/tests/utils/test_random_distribution_sampler.py +++ b/flepimop/gempyor_pkg/tests/utils/test_random_distribution_sampler.py @@ -4,6 +4,7 @@ import numpy as np import pytest +import re from gempyor.testing import partials_are_similar from gempyor.utils import random_distribution_sampler @@ -14,7 +15,7 @@ class TestRandomDistributionSampler: def test_not_implemented_error_exception(self, distribution: str) -> None: with pytest.raises( NotImplementedError, - match=rf"Unknown distribution [received: '{distribution}'].", + match=re.escape(rf"Unknown distribution [received: '{distribution}']."), ): random_distribution_sampler(distribution) @@ -22,7 +23,7 @@ def test_not_implemented_error_exception(self, distribution: str) -> None: def test_binomial_p_value_error(self, p: float) -> None: with pytest.raises( ValueError, - match=rf"Invalid `p-value`: '{p}' is out of range [0,1].", + match=re.escape(rf"Invalid `p-value`: '{p}' is out of range [0,1]."), ): random_distribution_sampler("binomial", n=100, p=p)