-
Notifications
You must be signed in to change notification settings - Fork 506
/
conftest.py
49 lines (32 loc) · 1.08 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
49
import os
import pytest
import voila.app
BASE_DIR = os.path.dirname(__file__)
class VoilaTest(voila.app.Voila):
def listen(self):
pass # the ioloop is taken care of by the pytest-tornado framework
@pytest.fixture
def voila_config():
return lambda app: None
@pytest.fixture
def voila_args_extra():
return []
@pytest.fixture
def voila_config_file_paths_arg():
# we don't want the tests to use any configuration on the system
return '--VoilaTest.config_file_paths=[]'
@pytest.fixture
def voila_args(voila_notebook, voila_args_extra, voila_config_file_paths_arg):
debug_args = ['--VoilaTest.log_level=DEBUG'] if os.environ.get('VOILA_TEST_DEBUG', False) else []
return [voila_notebook, voila_config_file_paths_arg] + voila_args_extra + debug_args
@pytest.fixture
def voila_app(voila_args, voila_config):
voila_app = VoilaTest.instance()
voila_app.initialize(voila_args + ['--no-browser'])
voila_config(voila_app)
voila_app.start()
yield voila_app
voila_app.clear_instance()
@pytest.fixture
def app(voila_app):
return voila_app.app