-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathtests.py
60 lines (52 loc) · 1.69 KB
/
tests.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
50
51
52
53
54
55
56
57
58
59
60
import unittest
from tutorial import introduction
from tutorial import getting_started
from tutorial import html_components
from tutorial import core_components
from tutorial import basic_callbacks
from tutorial import html_component_appendix
from tutorial import callbacks_with_dependencies
from tutorial import dynamic_content
from tutorial import external_css_and_js
from tutorial import open_problems
from tutorial import architecture
from tutorial import graph_callbacks
from tutorial import live_updates
from tutorial import urls
chapters = [
introduction,
getting_started,
html_components,
core_components,
basic_callbacks,
html_component_appendix,
callbacks_with_dependencies,
dynamic_content,
external_css_and_js,
open_problems,
architecture,
graph_callbacks,
live_updates,
urls
]
from tutorial.server import app
with open('tutorial/examples/getting_started.py', 'r') as f:
example = f.read()
# Use the global app assignment
if 'app = dash.Dash' not in example:
raise Exception("Didn't declare app")
example = example.replace('app = dash.Dash', '# app = dash.Dash')
local_variables = {'app': app}
# return the layout instead of assigning it to the global app
if 'app.layout = ' not in example:
raise Exception("app.layout not assigned")
example = example.replace('app.layout = ', 'layout = ')
# Remove the "# Run the server" commands
if 'app.run_server' not in example:
raise Exception("app.run_server missing")
example = example.replace(
'\n app.run_server',
'print("Running")\n # app.run_server'
)
output = {}
exec(example, local_variables, output)