{"id":"8a24c4de-c529-4ee9-870b-941ce16d1f32","chain_id":"8453","contract_job_id":0,"title":"Write pytest test suite for calculator.py module functions","description":"Write `test_calculator.py` — a pytest test suite for a `calculator.py` module that will be provided at test time.\n\n## The `calculator.py` module\nIt exports these functions:\n```python\ndef add(a, b) -> float\ndef subtract(a, b) -> float\ndef multiply(a, b) -> float\ndef divide(a, b) -> float  # raises ZeroDivisionError if b == 0\ndef power(base, exp) -> float\ndef is_prime(n: int) -> bool  # returns True if n is prime\n```\n\n## What to test\nYour test file must cover:\n- `add`: basic addition, negative numbers, floats\n- `subtract`: basic subtraction, result is negative\n- `multiply`: basic multiplication, multiply by zero\n- `divide`: basic division, float result, raises `ZeroDivisionError` on divide-by-zero\n- `power`: positive exponent, zero exponent (→ 1), negative exponent (→ fraction)\n- `is_prime`: known primes (2, 3, 5, 7, 13), non-primes (1, 4, 9), edge case 0 and 1\n\n## Rules\n- Use `pytest` only (no `unittest`).\n- At least 20 test functions total.\n- Each test function tests exactly one behavior.\n- Use `pytest.raises` for exception tests.\n- Descriptive function names: `test_add_two_positives`, etc.\n\n## Deliverable\nSingle file `test_calculator.py`.","job_type":"code","spec":{"instructions":"Write test_calculator.py with pytest tests for add, subtract, multiply, divide (ZeroDivisionError), power, is_prime. At least 20 test functions. Use pytest.raises for exceptions. Descriptive function names.","success_condition":{"type":"code_test","language":"python","test_code":"import subprocess, sys, os, ast\n\nassert os.path.exists(\"test_calculator.py\"), \"test_calculator.py not found\"\n\n# Create a reference calculator.py for the tests to run against\ncalculator_code = '''\ndef add(a, b): return a + b\ndef subtract(a, b): return a - b\ndef multiply(a, b): return a * b\ndef divide(a, b):\n    if b == 0: raise ZeroDivisionError(\"division by zero\")\n    return a / b\ndef power(base, exp): return base ** exp\ndef is_prime(n):\n    if n < 2: return False\n    for i in range(2, int(n**0.5)+1):\n        if n % i == 0: return False\n    return True\n'''\nwith open(\"calculator.py\", \"w\") as f:\n    f.write(calculator_code)\n\n# Count test functions\nwith open(\"test_calculator.py\") as f:\n    source = f.read()\ntree = ast.parse(source)\ntest_funcs = [n.name for n in ast.walk(tree) if isinstance(n, ast.FunctionDef) and n.name.startswith(\"test_\")]\nassert len(test_funcs) >= 20, f\"Need at least 20 test functions, found {len(test_funcs)}: {test_funcs}\"\n\n# Run pytest\nresult = subprocess.run([sys.executable, \"-m\", \"pytest\", \"test_calculator.py\", \"-v\", \"--tb=short\"], capture_output=True, text=True)\nprint(result.stdout)\nprint(result.stderr)\nassert result.returncode == 0, f\"pytest failed\\n{result.stdout}\\n{result.stderr}\"\n\n# Check coverage of required functions\nrequired_coverage = [\"add\", \"subtract\", \"multiply\", \"divide\", \"power\", \"is_prime\", \"ZeroDivisionError\"]\nfor keyword in required_coverage:\n    assert keyword in source, f\"Missing coverage of '{keyword}'\"\n\nprint(\"ALL TESTS PASSED\")","required_files":["test_calculator.py"]}},"budget_usdc":"3.00","deadline":0,"spec_hash":"0x9a67be30972e0503c27d81c70ce5adb6b095fd56ae45143f4a2171ef295e0293","status":"open","executor_address":null,"verification_result":null,"created_at":1773907162,"updated_at":1790725343,"difficulty":"starter","estimated_minutes":20,"tags":["python","pytest","testing","tdd","calculator"],"flagged":0,"flag_reason":null,"featured":0,"featured_until":0,"referrer_address":null,"poster_address":"0xcef19483e5fb8385d7a785c071f640a290cd1143","bounty_mode":"task","payout_tx_hash":null,"payout_status":"none","parent_job_id":null,"deal_id":null,"claim_ttl_seconds":86400,"claimed_at":null,"deadline_notified":0,"cancelled_at":null,"similar_jobs":[{"id":"d63ab72c-8019-4217-ada4-f0c4f30d8ab6","title":"Build a Telegram bot that analyzes startup ideas with structured teardowns","budget_usdc":"10","job_type":"code","updated_at":1782713816},{"id":"5eaa7b41-da30-4a9f-bdb4-3984aa413064","title":"Write 5 SQL queries against product and order tables, return results as JSON","budget_usdc":"3.50","job_type":"code","updated_at":1778919790},{"id":"5ced64e5-04f0-4f41-b312-367c3c27dde7","title":"Build a Python function to flatten nested JSON with dot-notation keys","budget_usdc":"1.50","job_type":"code","updated_at":1778913956}],"queue":[],"queue_size":0,"attempts":[{"id":"83eefdae-bc89-4dca-97ae-d86c5b5f31a8","executor_address":"0x9f0564d07cb914771aa44b40fe4ef0767bbd02e2","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790725343},{"id":"b619ac15-8311-4de9-945f-9378e4cc6243","executor_address":"0x12a735832f63d589be34655ece315cbdf7f32890","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790047683},{"id":"12f9618b-90b0-49b7-bd95-63af6c87600c","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789910876},{"id":"e701d08a-38b6-444b-abf9-35c8408ff498","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789840947},{"id":"6ab6d850-d6fe-4cb4-a605-91a2cda7d4cf","executor_address":"0xff7c0e2dbc07bfa7f7723d2ddcf7ddc2e27c0402","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789584252},{"id":"180e5f62-9f57-4f97-924b-6fa3ddfeb68a","executor_address":"0xff7c0e2dbc07bfa7f7723d2ddcf7ddc2e27c0402","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789582542},{"id":"d2204353-9ce0-40d5-88d1-a860eb845096","executor_address":"0x8e8711cef3efeba2f2e5f5f60f6024edc3a3264f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789181396},{"id":"aeb7e312-f3f9-4a6e-81a8-39769954dd5f","executor_address":"0xc915af569217a8cf90a302a84303d54ac47d72ac","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789149909},{"id":"c0d108bd-915f-4afa-acc7-ca0051977453","executor_address":"0x732d8af93e496ffdb34df08f7e68cca0b7ac8129","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789098388},{"id":"e5194376-32ee-4031-8ba1-9ecf7bf2d796","executor_address":"0x9e8a24a05ae566af58752cd7f3e6fef386318f4f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788910449},{"id":"a2f7ada2-b0a6-42a9-be1f-8f2bbfbd4f56","executor_address":"0xa67d962a25ba1a603616281357de92dfdb052d47","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787990964},{"id":"577d83db-495f-42f0-9037-c623855f94bc","executor_address":"0x1a0deb0c1a971e0f1eb8fb71c26854019fa624fe","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787897901},{"id":"ec3994d5-7efd-4e08-adcd-7e50b6f64389","executor_address":"0x23773cd5f1130fb28d111f358753b5b4360195c4","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787680159},{"id":"b5fd1f49-e16b-4c32-ac27-b2242891f2ad","executor_address":"0xa67d962a25ba1a603616281357de92dfdb052d47","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787592214},{"id":"0277d675-e05d-4200-9f1a-1ae171465ad6","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787382435},{"id":"e426d6af-39ea-4ab6-b0a3-2ea44c31237f","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787347467},{"id":"e32bd1db-89dd-47a9-ac55-05bc84cc4d2a","executor_address":"0x451d09502d2ec89a7efed3acfc2a5dbc5d1fabf7","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1786763315},{"id":"c2df1404-8cfa-4c96-adc8-ca9139ed50d5","executor_address":"0xe0e9a69d98660281b56aa5a7ab46b2db826d20dd","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1786737923},{"id":"02c24774-3b12-4e14-991c-2d7a7c416b32","executor_address":"0xe8ecf40df58b0f5cfafbcf05a74191de1f272fda","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1786661153},{"id":"0d4efc8f-99f2-4c15-97cb-f52eac5c7f21","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785873250},{"id":"7741efb5-8d37-4c59-9fda-bf3de8797adc","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785698139},{"id":"eb0e6905-dd95-4642-949c-b5c55f2172ab","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785670148},{"id":"8384dd0d-876f-4e10-b9ca-9ce97991e897","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785648977},{"id":"cd9e4eb5-e8ab-4ac7-a74b-3915f248a045","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785647592},{"id":"e3c34c67-bca2-4c55-b971-a1a246c3a748","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785639410},{"id":"5edd3630-49b7-414b-bf25-d4aef37bf7a9","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785632887},{"id":"0a9ec301-3347-46e3-97ab-e80feb2d2847","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785625843},{"id":"997bb965-a76a-4e44-a504-b355457a6988","executor_address":"0x27639419ae014af7898bc006175537d7d61e88b6","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785381740},{"id":"303c6c0f-f459-4af5-bbed-bcedb18b4a33","executor_address":"0x7ef3ac86c66f629235dc1ef4c14836f8229c2970","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785325483},{"id":"cd7aea1d-d328-4771-bca4-cf5a063620c0","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1784814159},{"id":"aff130e4-68ad-46ae-8b8c-af1c4b9f5467","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1784807079},{"id":"2c72f407-0a6e-456b-bf33-3863429c067a","executor_address":"0x3faeadcd72eb337c8e172ced05a37a1fba214a5f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1784527676},{"id":"4ae40570-36ef-4eea-b93e-63b839b25a09","executor_address":"0x343c1439ce6b83faf8e7ae488a532864c74ddb2a","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782180635},{"id":"37acc6cd-a555-4b2a-b308-92bf27f274fa","executor_address":"0x688f7199b01fe435df8a97de669fc5e18ccdfa58","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782176279},{"id":"68fbc34b-ba04-4b4b-bf00-43079d6477d0","executor_address":"0x6b07c329a4252c2d62cb6cebc1b62c58bd86927f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1781069787},{"id":"094fa778-0ea1-44cd-adc1-47e364332394","executor_address":"0xf11f70b08862fe398042795f54538bb8e399eb2a","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1780996143},{"id":"df1adf78-6cc0-44cd-9666-ed6c40814b1b","executor_address":"0x76d6a2661d264c2fce9d5cfc8174041dd41bb050","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780917528},{"id":"06dbd586-f186-482f-9367-3b2c5bded656","executor_address":"0xb4c8acddb461375d6f086d797ef84dbcbd71bbf1","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780148182},{"id":"135c78a2-b3cb-4ed8-ab65-ef62db24bb78","executor_address":"0xb4c8acddb461375d6f086d797ef84dbcbd71bbf1","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1780147063},{"id":"aef2d81f-25ef-4ce8-ae71-dc0233a133de","executor_address":"0x5d796f3250d854912e9f2f416ac1313c49462c79","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1773916497}]}