Skip to content

Commit

Permalink
gh-108580: hypothesis test to validate metadata
Browse files Browse the repository at this point in the history
A hypothesis strategy for generating structured core metadata and
equivalent unstructured text. Ensures that parsing the text using
PackageMetadata results in the same structure - a roundtrip test.
  • Loading branch information
orbisvicis committed Sep 6, 2023
1 parent 229c51f commit 2c3b72b
Show file tree
Hide file tree
Showing 3 changed files with 468 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Lib/importlib/metadata/_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
# when used as text.

# Split an RFC5233-ish list:
# 1. Alt 1: match single or double quotes and handle escape characters.
# 2. Alt 2: match anything except ',' followed by a space. If quote
# 1. Require a list separator, or beginning-of-string.
# 2. Alt 1: match single or double quotes and handle escape characters.
# 3. Alt 2: match anything except ',' followed by a space. If quote
# characters are unbalanced, they will be matched here.
# 3. Match the alternatives at least once, in any order...
# 4. ... and capture them.
# 5. Match the list separator, or end-of-string.
# 4. Match the alternatives at least once, in any order...
# 5. ... and capture them.
# Result:
# group 1 (list entry): None or non-empty string.

_entries = re.compile(r"""
( (?: (["']) (?:(?!\2|\\).|\\.)* \2 # 1
| (?!,\ ). # 2
)+ # 3
) # 4
(?:,\ |$) # 5
(?: (?<=,\ ) | (?<=^) ) # 1
( (?: (["']) (?:(?!\2|\\).|\\.)* \2 # 2
| (?!,\ ). # 3
)+ # 4
) # 5
""", re.VERBOSE)

# Split an RFC5233-ish name-email entry:
Expand Down
Loading

0 comments on commit 2c3b72b

Please sign in to comment.