Skip to content

Commit 7b4eaf1

Browse files
Create test_code.py
Signed-off-by: Fabiana 🚀 Campanari <[email protected]>
1 parent 3e0a51a commit 7b4eaf1

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)