We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0e7e9b8 + c8ac1b8 commit 91410efCopy full SHA for 91410ef
test_code.py
@@ -0,0 +1,26 @@
1
+
2
3
+#Test file for pytest. This example includes several test functions and uses pytest fixtures for setup and teardown.
4
5
+import pytest
6
+# Setup for configuration and cleanup
7
+@pytest.fixture
8
+def setup_data():
9
+ print("\nSetup")
10
+ data = {"key1": "value1", "key2": "value2"}
11
+ yield data
12
+ print("\nCleanup")
13
14
+# Test function using the fixture
15
+def test_key1(setup_data):
16
+ assert setup_data["key1"] == "value1"
17
18
+# Another test function using the fixture
19
+def test_key2(setup_data):
20
+ assert setup_data["key2"] == "value2"
21
22
+# Test function without using the fixture
23
+def test_addition():
24
+ assert 1 + 1 == 2
25
26
0 commit comments