Test Failed
Push — main ( 3c00a2...7c8c49 )
by torrua
02:08
created

tests.conftest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3
1
# -*- coding: utf-8 -*-
2
"""Defines fixtures available to all tests."""
3
4
import logging
5
6
import pytest
7
8
from loglan_db import db as _db, create_app
9
10
11
@pytest.fixture
12
def app():
13
    """Create application for the tests."""
14
    _app = create_app("tests.settings", _db)
15
    _app.logger.setLevel(logging.CRITICAL)
16
    ctx = _app.test_request_context()
17
    ctx.push()
18
19
    yield _app
20
21
    ctx.pop()
22
23
24
@pytest.fixture
25
def db(app):
26
    """Create database for the tests."""
27
    _db.app = app
28
    with app.app_context():
29
        _db.create_all()
30
31
    yield _db
32
33
    # Explicitly close DB connection
34
    _db.session.close()
35
    _db.drop_all()
36