~cnx/palace

ref: 708f23b35a7e232273ba0a63a65b3ef778a84540 palace/tests/unit/conftest.py -rw-r--r-- 1.2 KiB
708f23b3 — Ngô Ngọc Đức Huy Write tutorial for source effect 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Test fixtures for unit tests
# Copyright (C) 2020  Nguyễn Gia Phong
#
# This file is part of palace.
#
# palace is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# palace is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with palace.  If not, see <https://www.gnu.org/licenses/>.

"""This module provide default objects of palace classes as fixtures
for convenient testing.
"""

from pytest import fixture
from palace import Device, Context


@fixture(scope='session')
def device():
    """Provide the default device."""
    with Device() as dev: yield dev


@fixture(scope='session')
def context(device):
    """Provide a context creared from the default device
    (default context).
    """
    with Context(device) as ctx: yield ctx