![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
show where your regex match assertion failed!
pip install re-assert
re-assert
provides a helper class to make assertions of regexes simpler.
re_assert.Matches(pattern: str, *args, **kwargs)
construct a Matches
object.
note: under the hood, re-assert
uses the regex
library for matching,
any *args
/ **kwargs
that regex.compile
supports will work. in general,
the regex
library is 100% compatible with the re
library (and will even
accept its flags, etc.)
re_assert.Matches.from_pattern(pattern: Pattern[str]) -> Matches
construct a Matches
object from an already-compiled regex.
this is useful (for instance) if you're testing an existing compiled regex.
>>> import re
>>> reg = re.compile('foo')
>>> Matches.from_pattern(reg) == 'fork'
False
>>> Matches.from_pattern(reg) == 'food'
True
Matches.__eq__(other)
(==
)the equality operator is overridden for use with assertion frameworks such as pytest
>>> pat = Matches('foo')
>>> pat == 'bar'
False
>>> pat == 'food'
True
Matches.__repr__()
(repr(...)
)a side-effect of an equality failure changes the repr(...)
of a Matches
object. this allows for useful pytest assertion messages:
> assert Matches('foo') == 'fork'
E AssertionError: assert Matches('foo'...ork\n # ^ == 'fork'
E -Matches('foo')\n
E - # regex failed to match at:\n
E - #\n
E - #> fork\n
E - # ^
E +'fork'
Matches.assert_matches(s: str)
if you're using some other test framework, this method is useful for producing a readable traceback
>>> Matches('foo').assert_matches('food')
>>> Matches('foo').assert_matches('fork')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/asottile/workspace/re-assert/re_assert.py", line 63, in assert_matches
assert self == s, self._fail
AssertionError: regex failed to match at:
> fork
^
FAQs
show where your regex match assertion failed!
We found that re-assert demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.