flaxon-pytest
Pytest fixtures and utilities for testing Flaxon applications.
Installation
pip install flaxon-pytest
Quick Start
python
from flaxon import Flaxon
app = Flaxon("test-app")
@app.get("/")
async def home():
return {"message": "Hello"}
def test_home(flaxon_client):
response = flaxon_client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello"}
Fixtures
flaxon_client
Synchronous test client.
python
def test_route(flaxon_client):
response = flaxon_client.get("/")
assert response.status_code == 200
flaxon_async_client
Asynchronous test client.
python
@pytest.mark.asyncio
async def test_route(flaxon_async_client):
response = await flaxon_async_client.get("/")
assert response.status_code == 200
flaxon_app
Create a test application.
python
def test_custom_app(flaxon_app):
@flaxon_app.get("/custom")
async def custom():
return {"ok": True}
client = flaxon_app.test_client()
response = client.get("/custom")
assert response.status_code == 200
flaxon_websocket_client
WebSocket test client.
python
@pytest.mark.asyncio
async def test_websocket(flaxon_websocket_client):
await flaxon_websocket_client.connect("/ws/echo")
await flaxon_websocket_client.send_json({"message": "Hello"})
response = await flaxon_websocket_client.receive_json()
assert response["message"] == "Hello"
await flaxon_websocket_client.disconnect()
flaxon_temp_dir
Temporary directory for file tests.
python
def test_upload(flaxon_client, flaxon_temp_dir):
file_path = flaxon_temp_dir / "test.txt"
file_path.write_text("Hello")
# Upload file...
flaxon_db
In-memory database for tests.
python
async def test_db(flaxon_db):
await flaxon_db.execute("CREATE TABLE users (id INTEGER, name TEXT)")
await flaxon_db.execute("INSERT INTO users VALUES (1, 'Alice')")
row = await flaxon_db.fetch_one("SELECT * FROM users")
assert row["name"] == "Alice"
Assertions
assert_status
python
from flaxon_pytest import assert_status
assert_status(response, 200)
assert_json
python
from flaxon_pytest import assert_json
data = assert_json(response)
assert data["success"] is True
assert_success
python
from flaxon_pytest import assert_success
assert_success(response)
assert_error
python
from flaxon_pytest import assert_error
assert_error(response, code="FX-VAL-001")
assert_header
python
from flaxon_pytest import assert_header
assert_header(response, "x-request-id")
License
MIT
Metadata
Release files for flaxon-pytest 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flaxon_pytest-0.1.1.tar.gz | 9.1 kB | Without provenance | Details for flaxon_pytest-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flaxon_pytest-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for flaxon_pytest-0.1.1-py3-none-any.whl |
Total release size: 17.2 kB
Release files / flaxon_pytest-0.1.1.tar.gz
| Download URL | flaxon_pytest-0.1.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9d05c1814b232443281c575e99bb375fe3a045634e6eda9e27d98dc38ac1b70
|
|
BLAKE2b-256 checksum How to use checksums |
74940876081db287a706c3360b32c8dad4b1ba068c6ab434c47487850e5837d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / flaxon_pytest-0.1.1-py3-none-any.whl
| Download URL | flaxon_pytest-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e0766538d92214590f4caa01610135afbd9065881930b91870091cc05d54687
|
|
BLAKE2b-256 checksum How to use checksums |
1722b78e59956d7c47c22ec8ded44df5f7cfa1067b29887f3fbfb8d9ab4f8ae4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for flaxon-pytest 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.