API Reference¶
Plugin hooks¶
Fixture implementation¶
-
rampa.pytest_plugin.rampa_result(request)rampa.pytest_plugin.rampa_result(request)
Run a rampa scenario defined by
@pytest.mark.rampa_scenario.The marker accepts the same kwargs as
ScenarioConfigplus an optionalthresholdsdict. The fixture runs the scenario, waits for completion, and returns theRunResult.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:
unittest integration¶
-
class rampa.unittest_plugin.RampaTestCase¶class rampa.unittest_plugin.RampaTestCase¶
Bases:
objectMixin that adds
run_rampa()to aunittest.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