-
Notifications
You must be signed in to change notification settings - Fork 0
PyTest
Heath Brown edited this page Nov 12, 2023
·
4 revisions
- Use the
@pytest.mark.parametrize()
decorator
# file: tests/test_roku_api.py
import pytest
from roku.api import to_snake_case
TEST_SNAKE_CASE = [
#(input_string, expected)
("test", "test"),
("testTest", "test_test"),
("testTEST", "test_test"),
("test2Test", "test2_test"),
("TestTest", "test_test"),
("test-test", "test_test"),
("Test-test", "test_test"),
("TestTest-test", "test_test_test"),
("test-test-test", "test_test_test"),
("test-test-test-test", "test_test_test_test")
# Fails("Testtest-test", "test_test_test")
]
@pytest.mark.parametrize("input_string,expected", TEST_SNAKE_CASE)
def test_to_snake_case(input_string, expected):
assert to_snake_case(input_string) == expected
# file: tests/test_response_record.py
import requests
from responses import _recorder
url = "http://192.168.1.117:8060"
def another():
rsp = requests.get(url)
rsp = requests.post(url + "/keypress/HOME")
@_recorder.record(file_path="out.yaml")
def test_recorder():
another()