Skip to content

Commit

Permalink
Using re.escape() in regexs
Browse files Browse the repository at this point in the history
  • Loading branch information
emprzy committed Dec 2, 2024
1 parent 4bf61fb commit 660795f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,15 +15,15 @@ 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)

@pytest.mark.parametrize("p", [(-0.5), (1.2), (0.0), (1.0)])
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)

Expand Down

0 comments on commit 660795f

Please sign in to comment.