Skip to content

TP0303

Warning: warning: a test_ function that can’t be run as a test (M44, §20; reported only by taipan test)

  • '<f>' takes parameters, so it isn't run as a test (M44)

From the golden case tests/cases/m44/test_async.tpn:

test_async.tpn
# Async tests, shared state, and test_ functions that can't be tests (SPEC §20).
import asyncio
import sys
class Counter:
calls: ClassVar[int] = 0
async def double(n: int) -> int:
await asyncio.sleep(0)
return n * 2
async def test_double():
assert await double(2) == 4
Counter.calls += 1
def test_shared_state():
Counter.calls += 1
assert Counter.calls == 2
def test_with_parameter(n: int):
assert n > 0
def test_exit():
sys.exit(3)

The compiler reports:

test_async.tpn:20:5: warning TP0303: 'test_with_parameter' takes parameters, so it isn't run as a test

The specification lists every code.