API Reference

Plugin hooks

rampa.pytest_plugin.pytest_configure(config)
function
function
rampa.pytest_plugin.pytest_configure(config)

Register the rampa_scenario marker.

Parameters:

config (Any)

Return type:

None

Fixture implementation

rampa.pytest_plugin.rampa_result(request)
function
function
rampa.pytest_plugin.rampa_result(request)

Run a rampa scenario defined by @pytest.mark.rampa_scenario.

The marker accepts the same kwargs as ScenarioConfig plus an optional thresholds dict. The fixture runs the scenario, waits for completion, and returns the RunResult.

If thresholds are configured and any fail, the test fails with a descriptive message.

Parameters:

request (pytest.FixtureRequest) – Pytest request object.

Returns:

  • RunResult – The completed test run result.

  • >>> import rampa.pytest_plugin

Return type:

RunResult

unittest integration

class rampa.unittest_plugin.RampaTestCase
class
class
class rampa.unittest_plugin.RampaTestCase

Bases: object

Mixin that adds run_rampa() to a unittest.TestCase.

Usage:

class TestAPI(unittest.TestCase, RampaTestCase):
    async def worker(self, w: rampa.Worker) -> None:
        resp = await w.http.get("http://localhost/api")
        w.check(resp, {"status 200": lambda r: r.status == 200})

    def test_load(self) -> None:
        result = self.run_rampa(
            worker_fn=self.worker,
            executor="constant-vus",
            vus=5,
            duration="10s",
            thresholds={"http_req_duration": ["p(95)<500"]},
        )
        assert result.status == RunStatus.PASSED
>>> hasattr(RampaTestCase, 'run_rampa')
True

Internal

rampa.pytest_plugin._run_plan(plan)
async function
async function
rampa.pytest_plugin._run_plan(plan)

Run a test plan through the headless engine.

Parameters:

plan (TestPlan)

Return type:

RunResult