Replace assertion-free mock tests with tests that actually execute (2,513 mock occurrences)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Refactoring
- Chiarezza
- Da chiarire
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- distributed-systems, testing-qa
Direzione di ricerca
Inizia con i test problematici elencati in tests/test_executor_schedulers.py, tests/test_executor.py, tests/test_ssh_automation.py, tests/test_filesystem.py, tests/test_cloud_providers_aws.py, tests/test_kubernetes_integration.py e tests/test_executor_connections.py; esamina i fixture esistenti e la configurazione dei test real-world. Usa i criteri di accettazione per scegliere un sottosistema con ambito ristretto, quindi verifica che i test vengano eseguiti su target reali o vengano eliminati con una motivazione indicata e che tests/real_world/ non contenga mock.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Part of #108 · Phase 2 · Depends on the production-mock-removal issue
Problem
60 of 240 test files use mocks; 2,513 total occurrences of unittest.mock|MagicMock|AsyncMock|@patch|patch(|monkeypatch|Mock(. Three of them are inside tests/real_world/, defeating the purpose of that directory entirely.
The project's own rules state: "Do not use mock services for anything ever" and "All tests need to use 'real' function calls."
Representative offenders — tests that mock exactly the thing they claim to test
tests/test_executor_schedulers.py:73-131test_submit_slurm_job_basic— patchestempfile.NamedTemporaryFile,pickle.dump,os.unlink,setup_remote_environment,create_job_script, and stubsconnection_manager.execute_remote_commandto return"Submitted batch job 12345". Then assertsjob_id == "12345". It tests a regex against a string the test itself supplied. No SLURM is involved. Same pattern at:139,:212,:262,:321,:409.tests/test_executor.py:79 test_execute_command—@patch("paramiko.SSHClient"), setsmock_stdout.read.return_value = b"command output", assertsstdout == "command output". Asserts a mock returns what it was told to return.tests/test_ssh_automation.py:123 test_validate_ssh_key_success— mocksparamiko.SSHClient, assertsvalidate_ssh_key(...) is True. No key is ever validated.tests/test_filesystem.py:205 test_remote_ls— mocks SSH, feedsb"file1.txt\nfile2.py\nsubdir/\n", assertsls()returns those three names. Testsstr.splitandrstrip.tests/test_cloud_providers_aws.py:42-44 test_authenticate_success— patchesBOTO3_AVAILABLE = Trueandboto3. Passes on a machine with no boto3 installed at all.tests/test_kubernetes_integration.py:31— fixture patcheskubernetes.clientwholesale;create_namespaced_jobreturns aMockwhose.metadata.nameis"test-job-123". No cluster, no API.tests/test_executor_connections.py:72,103,144,190,215,234,253,279,295— every connection test patchesparamiko.SSHClient. The connection manager is never tested against a socket.
The standard to replace them with
For each subsystem, in preference order:
- Real execution against a real target. SSH/SLURM/PBS/SGE -> a container or the HF Jobs substrate. Filesystem -> a real temp dir and a real SFTP session.
- Real local server. Spin an actual sshd in a container; connect a real socket. This is what
test_executor_connections.pyshould do. - Recorded real interactions (e.g.
vcrpyfor pricing APIs) — recorded once from a genuine call, per the project's "verify with real calls, then record" rule for paid APIs. - Delete. A test that only asserts a mock's configured return value has negative value: it costs maintenance and creates false confidence. Deleting it raises the quality of the suite.
Acceptance criteria
-
grep -rn "unittest.mock" tests/real_world/returns zero — that directory is real-only by definition - Every test named in the list above is either rewritten against a real target or deleted with a stated reason
- Mock occurrences in
tests/reduced by at least an order of magnitude from 2,513 - Each supported backend has at least one test that submits a real job and asserts on a real returned value
- No test asserts equality against a string the same test supplied to a stub
Note
Expect the pass count to drop as this lands, and expect real bugs to surface. That is the point — the cloud-path KeyError in Phase 3 survived precisely because tests mocked past it.
- Lingua principale
- Python
- Stelle
- 10
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ContextLab/clustrix
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
ContextLab/clustrix#175 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
ContextLab/clustrix#170 ·
-
enhancement epic
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
ContextLab/clustrix#160 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
ContextLab/clustrix#155 · 1 commento ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
ContextLab/clustrix#151 · 5 commenti ·
Tutte le issue di ContextLab/clustrix
Issue simili
-
Atomic append fails to create a missing fileForse già presa @harbinresearcher l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
fabiocaccamo/python-fsutil#201 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
task
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
danparshall/claude_researcher#87 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
GhostManager/Ghostwriter#998 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
datajoint/datajoint-python#1586 ·
I maintainer di solito rispondono entro 1 giorno