Skip to content

The job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.

fix(tests): escape the regex in test_verify_pdf's docstring and compile-check tests/*.py (#503)

Yang97e25757951d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d782f557..edee454b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -105,6 +105,14 @@ per-file diff commands.
### Fixed
+- **The compile-warning check covers `tests/*.py` too** (`tests/test_verify_pdf.py`,
+ `tests/test_verify_layout.py`) - `FindNonAsciiDateRangesTests`' docstring quotes the regex
+ `\s*` unescaped, so Python 3.12+ prints a `SyntaxWarning` for the invalid escape `\s` when
+ the test module is compiled. It shows up in this repo's own CI log on 3.12, 3.13 and 3.14 while
+ the run stays green, and under `-W error::SyntaxWarning` the module fails to import. Escaped
+ in the docstring; `ToolsCompileWithoutWarnings` now compiles `tests/*.py` as well as
+ `tools/*.py` and fails on the unescaped version.
+
- **`linkedin-search detail` no longer fetches an unrelated posting for a URL on another
host** - `normalizeId` took the first 6+-digit path segment from *any* URL, so a
Greenhouse or Lever apply link (the kind a posting's own page hands out, and what a user
diff --git a/tests/test_verify_layout.py b/tests/test_verify_layout.py
index 5483c134..f9948720 100644
--- a/tests/test_verify_layout.py
+++ b/tests/test_verify_layout.py
@@ -177,15 +177,19 @@ class ToolsCompileWithoutWarnings(unittest.TestCase):
the warning lands in the middle of a verification report. Compiling is a
pure `compile()` over the source text - no cache file, no temp file - so the
check costs nothing and covers every `tools/*.py`, guarding the next
- docstring that quotes a macro too.
+ docstring that quotes a macro too. It covers `tests/*.py` as well: a test
+ docstring that quotes a regex (`\\s*` in `test_verify_pdf.py`) warned in CI
+ on every matrix Python while the run stayed green.
"""
def test_sources_have_no_invalid_escape_sequences(self):
import warnings
tools_dir = Path(verify_layout.__file__).resolve().parent
- sources = sorted(tools_dir.glob("*.py"))
+ tests_dir = Path(__file__).resolve().parent
+ sources = sorted(tools_dir.glob("*.py")) + sorted(tests_dir.glob("*.py"))
self.assertIn(Path(verify_layout.__file__).resolve(), sources)
+ self.assertIn(Path(__file__).resolve(), sources)
offenders: dict[str, list[str]] = {}
for source in sources:
with warnings.catch_warnings(record=True) as caught:
@@ -197,8 +201,8 @@ class ToolsCompileWithoutWarnings(unittest.TestCase):
if issubclass(w.category, (SyntaxWarning, DeprecationWarning))
]
if syntax:
- offenders[source.name] = syntax
- self.assertEqual({}, offenders, "tools/*.py warn about invalid escapes when compiled")
+ offenders[f"{source.parent.name}/{source.name}"] = syntax
+ self.assertEqual({}, offenders, "tools/*.py or tests/*.py warn about invalid escapes when compiled")
if __name__ == "__main__":
diff --git a/tests/test_verify_pdf.py b/tests/test_verify_pdf.py
index dee3ddec..ee2680d6 100644
--- a/tests/test_verify_pdf.py
+++ b/tests/test_verify_pdf.py
@@ -72,7 +72,7 @@ class FindNonAsciiDateRangesTests(unittest.TestCase):
The fold that makes `--contains "2016-2024"` pass on that layer (#458) is
what makes `--contains` unable to detect it - so this check never folds.
- The newline cases are yang2632's finding on the PR: `\s*` between year and
+ The newline cases are yang2632's finding on the PR: `\\s*` between year and
dash also matched a line break, so a heading ending in an ASCII date joined
a dash that merely opened the next line.
"""