Fix test collection and execution errors on Windows (geteuid, FileStore skip, bedrock tempfile lock)

Abierto Apto para principiantes
#2,027 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@prasad2512 ya está trabajando en esto.

Desde el 19/10/2026.

  • #2028 de @prasad2512 — abierto
  • #2035 de @Dopetaiga — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
aws, python
Área
devtools, testing

Línea de trabajo

Empieza en tests/lib/tools/test_file_store.py y tests/lib/tools/memory_sync/test_delete_discipline.py, donde los decoradores de os.geteuid necesitan comprobaciones de plataforma; compara sus marcadores de omisión con tests/lib/tools/memory_sync/test_memory_sync.py. Luego revisa mock_aws_config en tests/lib/test_bedrock.py y las tres pruebas de symlinks mencionadas en tests/lib/tools/test_agent_toolset.py. El trabajo estará terminado cuando se hayan corregido los fallos específicos de Windows durante la recopilación y ejecución, tal como se describe, y las pruebas afectadas se recopilen y ejecuten.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

Running the test suite on Windows (or collecting tests with pytest) encounters multiple crashes and collection failures due to POSIX assumptions in tests:

  1. AttributeError: module 'os' has no attribute 'geteuid' during test collection:
    In tests/lib/tools/test_file_store.py:207, 317 and tests/lib/tools/memory_sync/test_delete_discipline.py:168:

    @pytest.mark.skipif(os.geteuid() == 0, reason="permission checks do not bind root")
    

    Because os.geteuid does not exist on Windows, evaluating it in the decorator during pytest module import crashes collection immediately:

    AttributeError: module 'os' has no attribute 'geteuid'
    

    This prevents pytest from discovering or running any subsequent tests.

  2. Unskipped POSIX-only FileStore suites:
    FileStore explicitly requires _O_NOFOLLOW != 0 (_platform_supported()) and raises RuntimeError("FileStore requires O_NOFOLLOW support on this platform") on non-POSIX platforms. test_file_store.py carries:

    pytestmark = pytest.mark.skipif(os.name != "posix", reason="FileStore refuses non-POSIX platforms")
    

    However, tests/lib/tools/memory_sync/test_memory_sync.py and tests/lib/tools/memory_sync/test_delete_discipline.py were missing this file-level marker, causing 38 test failures on Windows.

  3. tempfile.NamedTemporaryFile file-locking contention in mock_aws_config:
    In tests/lib/test_bedrock.py:65:

    with tempfile.NamedTemporaryFile(mode="w+", delete=True) as temp_file:
        ...
        monkeypatch.setenv("AWS_CONFIG_FILE", str(temp_file.name))
        yield
    

    On Windows, an open NamedTemporaryFile(delete=True) cannot be opened by a second handle (boto3.Session). boto3 encounters a PermissionError [Errno 13], which botocore catches and translates to botocore.exceptions.ProfileNotFound, causing 4 test failures:

    • test_region_infer_from_profile
    • test_region_infer_from_specified_profile[default profile]
    • test_region_infer_from_specified_profile[custom profile]
    • test_region_infer_from_aws_profile_argument[profiles0]
  4. Missing @needs_symlinks marker on symlink tests:
    In tests/lib/tools/test_agent_toolset.py, three tests (test_read_through_symlink_escape_is_rejected, test_glob_post_filters_symlink_escape, and test_grep_skips_symlinked_files) create symlinks without carrying the @needs_symlinks marker, failing on Windows machines where symlink privileges are restricted (OSError: [WinError 1314]).

Expected Behavior
  • Guard os.geteuid() with os.name != "posix" so non-POSIX platforms skip cleanly without collection crashes.
  • Mark memory sync suites to skip on non-POSIX platforms matching test_file_store.py.
  • Use pytest's tmp_path fixture for mock_aws_config in test_bedrock.py to avoid Windows file-locking contention.
  • Apply @needs_symlinks to the remaining symlink tests in test_agent_toolset.py.
Lenguaje dominante
Python
Estrellas
4k
Forks
905
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de anthropics/anthropic-sdk-python

Todos los issues de anthropics/anthropic-sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.