Spaces:
Build error
Build error
Create conftest.py
Browse files- Test/conftest.py +23 -0
Test/conftest.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pytest
|
2 |
+
from my_app.models import FooModel, BarModel
|
3 |
+
|
4 |
+
@pytest.fixture
|
5 |
+
def foo_model():
|
6 |
+
"""Fixture function para crear una instancia de FooModel"""
|
7 |
+
yield FooModel()
|
8 |
+
|
9 |
+
@pytest.fixture
|
10 |
+
def bar_model():
|
11 |
+
"""Fixture function para crear una instancia de BarModel"""
|
12 |
+
yield BarModel()
|
13 |
+
|
14 |
+
@pytest.fixture(scope="session")
|
15 |
+
def db_connection():
|
16 |
+
"""Fixture function para crear una conexión a la base de datos"""
|
17 |
+
connection = create_database_connection()
|
18 |
+
yield connection
|
19 |
+
close_database_connection(connection)
|
20 |
+
def test_something(foo_model, bar_model, db_connection):
|
21 |
+
# Prueba que usa las fixture functions
|
22 |
+
assert foo_model.do_something() == bar_model.do_something()
|
23 |
+
assert db_connection.execute("SELECT COUNT(*) FROM tabla").fetchone()[0] > 0
|