fix(test): convert migration-collision tests from pytest to unittest (#2341)
CI failure: the Ops scripts (unittest) job runs `python -m unittest
discover` which doesn't have pytest installed. test_check_migration_
collisions.py imported pytest unconditionally, failing module import:
ImportError: Failed to import test module: test_check_migration_collisions
Traceback (most recent call last):
File ".../test_check_migration_collisions.py", line 12, in <module>
import pytest
ModuleNotFoundError: No module named 'pytest'
The tests use no pytest-specific features (just bare assert + plain
class). Sibling test_sweep_cf_decide.py in the same dir already uses
unittest.TestCase. Convert this one to match: drop the pytest import,
make TestMigrationFileRe inherit from unittest.TestCase.
unittest.TestLoader.discover() requires TestCase subclasses for
auto-discovery, so the fix is two lines (drop import, add base).
Bare assert statements work fine inside TestCase methods.
Verified: `python3 -m unittest scripts.ops.test_check_migration_collisions -v`
runs all 9 tests, all pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ea8ff626a9
commit
b5df2126b9
@ -4,13 +4,14 @@ classifier + the diff/base-set logic that runs without git.
|
||||
The end-to-end git diff + gh pr list path is exercised manually (running
|
||||
the workflow against test PRs). These tests pin the pure-logic surface
|
||||
so a regression in migration-name parsing fails immediately at PR time.
|
||||
|
||||
Run locally: ``python3 -m unittest scripts/ops/test_check_migration_collisions.py -v``
|
||||
"""
|
||||
|
||||
import importlib.util
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
# Load the script as a module without invoking main(). We import the
|
||||
# regex + helpers directly so we can test them without setting up git.
|
||||
SCRIPT_PATH = Path(__file__).parent / "check_migration_collisions.py"
|
||||
@ -19,7 +20,7 @@ ccm = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(ccm)
|
||||
|
||||
|
||||
class TestMigrationFileRe:
|
||||
class TestMigrationFileRe(unittest.TestCase):
|
||||
"""The regex classifier — the load-bearing piece of the detector."""
|
||||
|
||||
def test_matches_standard_three_digit_prefix(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user