Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -1184,32 +1184,6 @@ COPY <<"EOF" /entrypoint_exec.sh
exec /bin/bash "${@}"
EOF

# The content below is automatically copied from scripts/docker/patch_cassandra_type_code.py
COPY <<"EOF" /patch_cassandra_type_code.py
#!/usr/bin/env python

from __future__ import annotations

import cassandra.type_codes as cassandra_type_codes

if __name__ == "__main__":
print()
path_to_patch = cassandra_type_codes.__file__
with open(path_to_patch, "r+") as f:
content = f.read()
if "PYTEST_DONT_REWRITE" in content:
print(f"The {path_to_patch} is already patched with PYTEST_DONT_REWRITE")
print()
exit(0)
f.seek(0)
content = content.replace('"""', '"""\nPYTEST_DONT_REWRITE', 1)
f.write(content)
f.truncate()
print(f"Patched {path_to_patch} with PYTEST_DONT_REWRITE")
print()
exit(0)
EOF

FROM ${PYTHON_BASE_IMAGE} as main

# Nolog bash flag is currently ignored - but you can replace it with other flags (for example
Expand Down Expand Up @@ -1424,15 +1398,6 @@ RUN bash /scripts/docker/install_pip_version.sh; \
bash /scripts/docker/install_additional_dependencies.sh; \
fi

COPY --from=scripts patch_cassandra_type_code.py /patch_cassandra_type_code.py

# Patch cassandra type_code to avoide accidental type_code assert rewriting breaking pytest
# test discovery and execution.
# This one can be fixed once https://github.com/pytest-dev/pytest/issues/10844
# is fixed and released or once the workaround is merged in cassandra-driver
# https://github.com/datastax/python-driver/pull/1142
RUN python /patch_cassandra_type_code.py

# Install autocomplete for airflow
RUN if command -v airflow; then \
register-python-argcomplete airflow >> ~/.bashrc ; \
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ filterwarnings = [
"ignore::DeprecationWarning:apispec.utils",
]
python_files = [
"*.py",
"test_*.py",
]
testpaths = [
"tests",
Expand Down
38 changes: 0 additions & 38 deletions scripts/docker/patch_cassandra_type_code.py

This file was deleted.

11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,3 +905,14 @@ def clear_lru_cache():

ExecutorLoader.validate_database_executor_compatibility.cache_clear()
_get_grouped_entry_points.cache_clear()


@pytest.fixture(autouse=True)
def refuse_to_run_test_from_wrongly_named_files(request):
filename: str = request.node.fspath.basename
if not request.node.fspath.basename.startswith("test_"):
raise Exception(
f"All test method files in tests/ must start with 'test_'. Seems that {filename} "
f"contains {request.function} that looks like a test case. Please rename the file to "
f"follow the test_* pattern if you want to run the tests in it."
)