Skip to content

Commit cb58822

Browse files
committed
Add some fixtures typing
1 parent 003675f commit cb58822

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from datetime import datetime
2+
from typing import NoReturn
23

34
import mongoengine
45
import pytest
@@ -9,7 +10,7 @@
910

1011

1112
@pytest.fixture(autouse=True, scope="session")
12-
def session_clean_up():
13+
def session_clean_up() -> NoReturn:
1314
"""Mandatory tests environment clean up before/after test session."""
1415
client = MongoClient("localhost", 27017)
1516
client.drop_database("flask_mongoengine_test_db")
@@ -24,7 +25,7 @@ def session_clean_up():
2425

2526

2627
@pytest.fixture()
27-
def app():
28+
def app() -> Flask:
2829
app = Flask(__name__)
2930
app.config["TESTING"] = True
3031
app.config["WTF_CSRF_ENABLED"] = False
@@ -36,7 +37,7 @@ def app():
3637

3738

3839
@pytest.fixture()
39-
def db(app):
40+
def db(app) -> MongoEngine:
4041
app.config["MONGODB_HOST"] = "mongodb://localhost:27017/flask_mongoengine_test_db"
4142
test_db = MongoEngine(app)
4243
db_name = (

tests/test_debug_panel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
- Independent of global configuration by design.
55
"""
6-
76
import contextlib
87

98
import jinja2
@@ -18,14 +17,15 @@
1817
from pytest_mock import MockerFixture
1918

2019
from flask_mongoengine.panels import (
20+
MongoCommandLogger,
2121
MongoDebugPanel,
2222
_maybe_patch_jinja_loader,
2323
mongo_command_logger,
2424
)
2525

2626

2727
@pytest.fixture()
28-
def app_no_mongo_monitoring():
28+
def app_no_mongo_monitoring() -> Flask:
2929
app = Flask(__name__)
3030
app.config["TESTING"] = True
3131
app.config["WTF_CSRF_ENABLED"] = False
@@ -39,7 +39,7 @@ def app_no_mongo_monitoring():
3939

4040

4141
@pytest.fixture(autouse=True)
42-
def registered_monitoring():
42+
def registered_monitoring() -> MongoCommandLogger:
4343
"""Register/Unregister mongo_command_logger in required tests"""
4444
monitoring.register(mongo_command_logger)
4545
mongo_command_logger.reset_tracker()
@@ -69,7 +69,7 @@ class TestMongoDebugPanel:
6969
"""Trivial tests to highlight any unexpected changes in namings or code."""
7070

7171
@pytest.fixture
72-
def toolbar_with_no_flask(self):
72+
def toolbar_with_no_flask(self) -> MongoDebugPanel:
7373
"""Simple instance of MongoDebugPanel without flask application"""
7474
jinja2_env = jinja2.Environment()
7575
return MongoDebugPanel(jinja2_env)
@@ -186,7 +186,7 @@ class TestMongoCommandLogger:
186186
"""By design tested with raw pymongo."""
187187

188188
@pytest.fixture(autouse=True)
189-
def py_db(self, registered_monitoring):
189+
def py_db(self, registered_monitoring) -> pymongo.MongoClient:
190190
"""Clean up and returns special database for testing on pymongo driver level"""
191191
client = pymongo.MongoClient("localhost", 27017)
192192
db = client.pymongo_test_database

0 commit comments

Comments
 (0)