-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_code.py
More file actions
24 lines (19 loc) · 639 Bytes
/
test_code.py
File metadata and controls
24 lines (19 loc) · 639 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
# Arquivo de teste para o pytest. Este exemplo inclui várias funções de teste e usa fixtures
# do pytest para configuração e limpeza
import pytest
# Fixture para configuração e limpeza
@pytest.fixture
def setup_data():
print("\nSetup")
data = {"key1": "value1", "key2": "value2"}
yield data
print("\nCleanup")
# Função de teste usando a fixture
def test_key1(setup_data):
assert setup_data["key1"] == "value1"
# Outra função de teste usando a fixture
def test_key2(setup_data):
assert setup_data["key2"] == "value2"
# Função de teste sem usar a fixture
def test_addition():
assert 1 + 1 == 2