CodeSampleX

Sample

pytest-asyncio 1.4.0: pytest.mark.asyncio, pytest_asyncio.fixture, pytest_asyncio.is_async_test

Verified sample for pypi pytest-asyncio 1.4.0: pytest.mark.asyncio, pytest_asyncio.fixture, pytest_asyncio.is_async_test. The contract ran on python 3.12 …

sha256:c6213c0528aae941777634d4ec531097bc4a65164fe99abb50e50b52dc99865a

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment python 3.12 linux 24 · alpine · musl x64 python 3.12 python pip 24

Verification-run environments

Environment Contract Stages Run
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-27

Case

HOW
Goal
verify pkg:pypi/pytest-asyncio@1.4.0
Packages
Symbols
  • pytest.mark.asyncio
  • pytest_asyncio.fixture
  • pytest_asyncio.is_async_test
Environment
python 3.12
Created
2026-08-27T19:42:47Z

Contract

  1. pytest.mark.asyncio marks coroutine functions with asyncio marker
  2. pytest_asyncio.fixture decorator creates asynchronous fixture definitions
  3. pytest_asyncio.is_async_test verifies whether a test item is a PytestAsyncioFunction
  4. pytest.main executes async test suites with async fixtures and returns ExitCode.OK
  5. async generator fixtures execute setup before test and teardown after test execution

Files

  • PROMPT.md
  • csx.json
  • pyproject.toml
  • requirements.txt
  • spec.json
  • test/contract.py

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:pypi/pytest-asyncio@1.4.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/pytest-asyncio@1.4.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:50f5f5697ecdecc5d90d1eaabcb6b765073399fa78d32dc1ba1f162582419224","constraints":{"executionContext":"python"},"contract":["pytest.mark.asyncio marks coroutine functions with asyncio marker","pytest_asyncio.fixture decorator creates asynchronous fixture definitions","pytest_asyncio.is_async_test verifies whether a test item is a PytestAsyncioFunction","pytest.main executes async test suites with async fixtures and returns ExitCode.OK","async generator fixtures execute setup before test and teardown after test execution"],"goal":"verify pkg:pypi/pytest-asyncio@1.4.0","kind":"HOW","packages":["pkg:pypi/pytest-asyncio@1.4.0"],"schemaVersion":1,"symbols":["pytest.mark.asyncio","pytest_asyncio.fixture","pytest_asyncio.is_async_test"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"pypi","executionContext":"python","language":"python","libc":"musl","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pytest-asyncio@1.4.0"],"schemaVersion":1,"subject":"pkg:pypi/pytest-asyncio@1.4.0","symbols":["pytest.mark.asyncio","pytest_asyncio.fixture","pytest_asyncio.is_async_test"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "verify-pytest-asyncio"
version = "0.1.0"
dependencies = [
    "iniconfig==2.3.0",
    "packaging==26.3",
    "pluggy==1.6.0",
    "pygments==2.21.0",
    "pytest==9.1.1",
    "typing-extensions==4.12.2",
    "pytest-asyncio==1.4.0",
]
requirements.txt
iniconfig==2.3.0
packaging==26.3
pluggy==1.6.0
pygments==2.21.0
pytest==9.1.1
typing-extensions==4.12.2
pytest-asyncio==1.4.0
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/pytest-asyncio@1.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/pytest-asyncio@1.4.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.py
import asyncio
import inspect
import os
import sys
import tempfile
import pytest
import pytest_asyncio
from pytest_asyncio.plugin import PytestAsyncioFunction


def test_mark_asyncio():
    @pytest.mark.asyncio
    async def sample_async_test():
        await asyncio.sleep(0.001)
        return 42

    assert hasattr(sample_async_test, "pytestmark")
    mark_names = [m.name for m in sample_async_test.pytestmark]
    assert "asyncio" in mark_names


def test_fixture_decorator():
    @pytest_asyncio.fixture
    async def sample_async_fixture():
        await asyncio.sleep(0.001)
        return "fixture_value"

    assert callable(sample_async_fixture)
    assert sample_async_fixture.__name__ == "sample_async_fixture"


def test_is_async_test():
    class DummySyncItem:
        pass

    assert issubclass(PytestAsyncioFunction, object)
    assert pytest_asyncio.is_async_test(DummySyncItem()) is False


def test_pytest_main_executes_async_suite():
    test_code = """import asyncio
import pytest
import pytest_asyncio

@pytest_asyncio.fixture
async def async_resource():
    yield "ready"

@pytest.mark.asyncio
async def test_async_function(async_resource):
    assert async_resource == "ready"
    await asyncio.sleep(0.001)
    assert 1 + 1 == 2
"""
    with tempfile.TemporaryDirectory() as tmp_dir:
        test_file = os.path.join(tmp_dir, "test_async_suite.py")
        with open(test_file, "w", encoding="utf-8") as f:
            f.write(test_code)

        exit_code = pytest.main(["-q", "--no-header", "-p", "pytest_asyncio", test_file])
        assert exit_code == pytest.ExitCode.OK


def test_async_generator_fixture_lifecycle():
    test_code = """import asyncio
import pytest
import pytest_asyncio

lifecycle_events = []

@pytest_asyncio.fixture
async def managed_resource():
    lifecycle_events.append("setup")
    yield {"status": "ok"}
    lifecycle_events.append("teardown")

@pytest.mark.asyncio
async def test_lifecycle(managed_resource):
    assert managed_resource["status"] == "ok"
    lifecycle_events.append("running")
    await asyncio.sleep(0.001)

def test_verify_lifecycle_ran():
    assert lifecycle_events == ["setup", "running", "teardown"]
"""
    with tempfile.TemporaryDirectory() as tmp_dir:
        test_file = os.path.join(tmp_dir, "test_lifecycle.py")
        with open(test_file, "w", encoding="utf-8") as f:
            f.write(test_code)

        exit_code = pytest.main(["-q", "--no-header", "-p", "pytest_asyncio", test_file])
        assert exit_code == pytest.ExitCode.OK


def main():
    test_mark_asyncio()
    test_fixture_decorator()
    test_is_async_test()
    test_pytest_main_executes_async_suite()
    test_async_generator_fixture_lifecycle()
    print("All contract assertions passed.")


if __name__ == "__main__":
    main()

Origin Seeder

anonymous