Skip to content

Commit d3d46dd

Browse files
committed
test(e2e): drop POSIX regex workaround + use [test] extras
Upstream pve-openapi@9deff0a's pattern-sanitize.ts now expands POSIX character classes, so PDM field_validator regexes evaluate correctly in Python's `re` module without the conftest monkey-patch. Workflow simplified to `pip install -e .[test]` (template now ships optional-dependencies). PDM workflow step name also corrected to "Start PDM test container" (was leftover "PBS" from the bulk-translate).
1 parent b353bb1 commit d3d46dd

2 files changed

Lines changed: 3 additions & 30 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ jobs:
1919
cache: pip
2020

2121
- name: Install package + test deps
22-
# Install test deps explicitly rather than via `[test]` extras: the
23-
# generator overwrites pyproject.toml on each regen and currently drops
24-
# `[project.optional-dependencies]`. Until the upstream Mustache
25-
# template carries the block, the workflow owns the deps list.
26-
run: |
27-
pip install -e .
28-
pip install 'pytest>=8' 'pytest-timeout>=2.3' 'requests>=2.32'
22+
run: pip install -e .[test]
2923

3024
- name: Authenticate to GHCR
3125
uses: docker/login-action@v3
@@ -34,7 +28,7 @@ jobs:
3428
username: ${{ github.actor }}
3529
password: ${{ secrets.GITHUB_TOKEN }}
3630

37-
- name: Start PBS test container
31+
- name: Start PDM test container
3832
id: proxmox
3933
uses: client-api/proxmox-docker-action@v1
4034
with:

e2e/conftest.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
11
"""Shared pytest fixtures for the PDM E2E suite."""
22
from __future__ import annotations
33

4-
import re as _re
54
from typing import Iterator
65

7-
# Generator gap workaround: PDM regex patterns use POSIX character classes like
8-
# `[:cntrl:]` / `[:^cntrl:]` which Python's `re` doesn't support — `re.match`
9-
# silently returns None for any input, so EVERY field_validator on PDM models
10-
# raises ValueError, including for legitimate values like 'root@pam'. We patch
11-
# `re.match` for the test process to bypass POSIX-class patterns; this is a
12-
# workaround until the generator translates these to PCRE-compatible regexes
13-
# (or the spec switches to a Python-friendly syntax).
14-
_POSIX_CLASS_MARKERS = ("[:cntrl:]", "[:^cntrl:]", "[:alpha:]", "[:digit:]",
15-
"[:alnum:]", "[:upper:]", "[:lower:]", "[:space:]")
16-
_orig_re_match = _re.match
17-
18-
19-
def _patched_re_match(pattern, string, flags=0): # type: ignore[no-untyped-def]
20-
if isinstance(pattern, str) and any(m in pattern for m in _POSIX_CLASS_MARKERS):
21-
return _orig_re_match(r"^.*$", string, flags) or _orig_re_match(r"", string, flags)
22-
return _orig_re_match(pattern, string, flags)
23-
24-
25-
_re.match = _patched_re_match # type: ignore[assignment]
26-
27-
import pytest # noqa: E402 (must come after the patch so any pytest imports also see it)
6+
import pytest
287

298
from clientapi_pdm import Pdm
309
from e2e.helpers.clients import token_client

0 commit comments

Comments
 (0)