Skip to content

Commit 3899988

Browse files
Merge pull request #178 from Quantum-Software-Development/FabianaCampanari-patch-1
Create test_code.py
2 parents 3e0a51a + 7b4eaf1 commit 3899988

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test_code.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Arquivo de teste para o pytest. Este exemplo inclui várias funções de teste e usa fixtures
3+
# do pytest para configuração e limpeza
4+
import pytest
5+
6+
# Fixture para configuração e limpeza
7+
@pytest.fixture
8+
def setup_data():
9+
print("\nSetup")
10+
data = {"key1": "value1", "key2": "value2"}
11+
yield data
12+
print("\nCleanup")
13+
14+
# Função de teste usando a fixture
15+
def test_key1(setup_data):
16+
assert setup_data["key1"] == "value1"
17+
18+
# Outra função de teste usando a fixture
19+
def test_key2(setup_data):
20+
assert setup_data["key2"] == "value2"
21+
22+
# Função de teste sem usar a fixture
23+
def test_addition():
24+
assert 1 + 1 == 2

0 commit comments

Comments
 (0)