forked from kwikteam/phy-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
48 lines (33 loc) · 1.04 KB
/
conftest.py
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
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""py.test utilities."""
#------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
import logging
import numpy as np
import os
from pytest import yield_fixture
from phy import add_default_handler
from phy.utils.tempdir import TemporaryDirectory
#------------------------------------------------------------------------------
# Common fixtures
#------------------------------------------------------------------------------
logging.getLogger().setLevel(logging.DEBUG)
add_default_handler('DEBUG')
# Fix the random seed in the tests.
np.random.seed(2015)
@yield_fixture
def tempdir():
with TemporaryDirectory() as tempdir:
yield tempdir
@yield_fixture
def chdir_tempdir():
curdir = os.getcwd()
with TemporaryDirectory() as tempdir:
os.chdir(tempdir)
yield tempdir
os.chdir(curdir)
@yield_fixture
def tempdir_bis():
with TemporaryDirectory() as tempdir:
yield tempdir