Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test_code.py #3459

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions test_code.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# Test file for pytest. This example includes several test functions and uses pytest fixtures for setup and teardown.


import pytest

# Fixture para configuração e limpeza
# "Fixture for setup and cleanup".
@pytest.fixture
def setup_data():
print("\nSetup")
data = {"key1": "value1", "key2": "value2"}
yield data
print("\nCleanup")

# Função de teste usando a fixture
# "Test function using the fixture."
def test_key1(setup_data):
assert setup_data["key1"] == "value1"

# Outra função de teste usando a fixture
# "Another test function using the fixture"
def test_key2(setup_data):
assert setup_data["key2"] == "value2"

# Função de teste sem usar a fixture
# "Test function without using the fixture"
def test_addition():
assert 1 + 1 == 2
Loading