attrs/tests
wouter bolsterlee 1759260aa0
Add support for re.Pattern to validators.matches_re() (#877)
Fixes #875.

This adds support for pre-compiled regular expressions to
attr.validators.matches_re(). This cannot be combined with flags since
the pre-compiled pattern already has those.

Detailed changes:

- attr.validators.matches_re() now accepts re.Pattern in addition to
  strings; update type annotations accordingly.
- Convert percent-formatting into str.format() for an error message
- Simplify (private) _MatchesReValidator helper class a bit: use the
  actual compiled pattern, and drop the unused .flags attribute.
- Simplify control flow a bit; add pointer about fullmatch emulation.
- Add tests
- Tweak existing test to ensure that .fullmatch() actually works
  correctly by matching a pattern that also matches (but not
  ‘full-matches’) a shorter substring.

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-11-30 06:32:24 +01:00
..
__init__.py
attr_import_star.py Make `from attr import *` work again on recent python versions. (#848) 2021-10-04 16:23:50 +02:00
dataclass_transform_example.py Implement pyright support via dataclass_transforms (#796) 2021-05-05 10:24:53 +02:00
strategies.py __attrs_pre_init__ (#750) 2021-01-25 07:31:37 +01:00
test_3rd_party.py Rename for clarity 2021-11-21 15:16:28 +01:00
test_annotations.py Fix bug in resolve_types with subclasses (#843) 2021-09-19 21:04:55 +02:00
test_cmp.py New attr.cmp_using helper function (#787) 2021-05-01 14:21:37 +02:00
test_compat.py Fix Python 2 2021-11-24 12:10:13 +01:00
test_config.py
test_converters.py Inline distutils.util.strtobool in tests (closes #813) (#830) 2021-08-10 07:45:28 +02:00
test_dunders.py Pull thread-local into _compat module to fix cloudpickling. (#857) 2021-11-04 06:52:10 +01:00
test_filters.py Avoid whitelist/blacklist terminology (#878) 2021-11-29 20:35:59 +01:00
test_funcs.py Revert recursive evolve (#806) 2021-05-06 15:26:27 +02:00
test_functional.py Optimize the case of on_setattr=validate & no validators (#817) 2021-05-17 09:24:46 +02:00
test_hooks.py Convert transformed attrs to AttrsClass (#824) 2021-09-22 21:58:32 +02:00
test_import.py Make `from attr import *` work again on recent python versions. (#848) 2021-10-04 16:23:50 +02:00
test_init_subclass.py
test_make.py Minor polish to #815 2021-05-18 11:29:29 +02:00
test_mypy.yml Fix mypy tests. Looks like the tests are error order sensitive (#856) 2021-10-30 21:05:49 +02:00
test_next_gen.py Clarify next-gen auto_attribs inference rules (#742) 2020-12-30 12:53:43 +01:00
test_pattern_matching.py Minor polish to #815 2021-05-18 11:29:29 +02:00
test_pyright.py Implement pyright support via dataclass_transforms (#796) 2021-05-05 10:24:53 +02:00
test_setattr.py Don't reset custom __setattr__ in slotted classes (#681) 2020-09-05 09:46:06 +02:00
test_slots.py Minor word smithing 2021-01-11 07:46:30 +01:00
test_validators.py Add support for re.Pattern to validators.matches_re() (#877) 2021-11-30 06:32:24 +01:00
test_version_info.py Rename _version.py into _version_info.py 2019-10-02 16:12:03 +02:00
typing_example.py Add support for re.Pattern to validators.matches_re() (#877) 2021-11-30 06:32:24 +01:00
utils.py Fix attribute collection (#635) 2020-04-06 11:41:52 +02:00