From c8ac1b8b4014a2e74d7a9593d7f658e8d1a4bdf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiana=20=20=E2=9A=A1=EF=B8=8F=20Campanari?= <113218619+FabianaCampanari@users.noreply.github.com> Date: Sat, 23 Aug 2025 22:20:04 -0300 Subject: [PATCH] Add pytest test functions with fixtures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test file includes multiple test functions and uses pytest fixtures for setup and teardown. Signed-off-by: Fabiana ⚡️ Campanari <113218619+FabianaCampanari@users.noreply.github.com> --- test_code.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test_code.py diff --git a/test_code.py b/test_code.py new file mode 100644 index 0000000..ceff903 --- /dev/null +++ b/test_code.py @@ -0,0 +1,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 + +