-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_code.py
More file actions
26 lines (18 loc) · 625 Bytes
/
test_code.py
File metadata and controls
26 lines (18 loc) · 625 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Test file for pytest. This example includes several test functions and uses pytest fixtures for setup and teardown.
import pytest
# Setup for configuration and cleanup
@pytest.fixture
def setup_data():
print("\nSetup")
data = {"key1": "value1", "key2": "value2"}
yield data
print("\nCleanup")
# Test function using the fixture
def test_key1(setup_data):
assert setup_data["key1"] == "value1"
# Another test function using the fixture
def test_key2(setup_data):
assert setup_data["key2"] == "value2"
# Test function without using the fixture
def test_addition():
assert 1 + 1 == 2