File: dummy.py

package info (click to toggle)
python-molotov 2.7-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,268 kB
  • sloc: python: 4,121; makefile: 60
file content (22 lines) | stat: -rw-r--r-- 563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
""" Molotov-based test.
"""
import random
from time import sleep

import molotov


@molotov.global_setup()
def starting(args):
    print("This is a dummy load test that runs against example.com")
    print("Some random failures were added on purpose (1%)")
    print("The test will start the Molotov console in 5 secs")
    sleep(5)


@molotov.scenario()
async def scenario_one(session):
    async with session.get("http://example.com") as resp:
        if random.randint(1, 100) == 5:
            raise AssertionError("Failed")
        assert resp.status == 200