Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit fa82eeb

Browse files
jbamptonMarc-Andre-Rivet
authored andcommitted
Add flake8 to CircleCI and enable for the test folder (#342)
1 parent 29b72b2 commit fa82eeb

File tree

5 files changed

+37
-35
lines changed

5 files changed

+37
-35
lines changed

.circleci/config.yml

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ jobs:
4343
name: npm run lint
4444
command: npm run lint
4545

46+
- run:
47+
name: python run lint
48+
command: |
49+
. venv/bin/activate
50+
flake8 --ignore=E501,F401,F841,F811 test
51+
4652
- run:
4753
name: Build
4854
command: |

dev-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ selenium
55
pandas
66
dash_table_experiments
77
xlrd
8+
flake8

test/IntegrationTests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import absolute_import
2-
import os
32
import multiprocessing
3+
import os
4+
import platform
5+
import threading
46
import time
57
import unittest
68
import percy
7-
import threading
8-
import platform
99
import flask
1010
import requests
1111

test/test_dash_import.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
class TestDashImport(unittest.TestCase):
66
def setUp(self):
77
with open('dash.py', 'w') as f:
8-
pass
9-
8+
pass
9+
1010
def tearDown(self):
1111
try:
1212
os.remove('dash.py')
1313
os.remove('dash.pyc')
1414
except OSError:
1515
pass
16-
16+
1717
def test_dash_import(self):
1818
"""Test that program exits if the wrong dash module was imported"""
19-
19+
2020
with self.assertRaises(SystemExit) as cm:
2121
import dash_core_components
2222

test/test_integration.py

+23-28
Original file line numberDiff line numberDiff line change
@@ -502,14 +502,15 @@ def test_tabs_in_vertical_mode(self):
502502
dcc.Tab(label='Tab three', value='tab-3', id='tab-3', children=[
503503
html.Div('Tab Three Content')
504504
]),
505-
], vertical=True),
505+
], vertical=True),
506506
html.Div(id='tabs-content')
507507
])
508508

509509
self.startServer(app=app)
510510
self.wait_for_text_to_equal('#tab-3', 'Tab three')
511511

512512
self.snapshot('Tabs - vertical mode')
513+
513514
def test_tabs_without_children(self):
514515
app = dash.Dash(__name__)
515516

@@ -518,18 +519,18 @@ def test_tabs_without_children(self):
518519
dcc.Tabs(id="tabs", value='tab-2', children=[
519520
dcc.Tab(label='Tab one', value='tab-1', id='tab-1'),
520521
dcc.Tab(label='Tab two', value='tab-2', id='tab-2'),
521-
]),
522+
]),
522523
html.Div(id='tabs-content')
523524
])
524525

525526
@app.callback(dash.dependencies.Output('tabs-content', 'children'),
526-
[dash.dependencies.Input('tabs', 'value')])
527+
[dash.dependencies.Input('tabs', 'value')])
527528
def render_content(tab):
528-
if(tab == 'tab-1'):
529+
if tab == 'tab-1':
529530
return html.Div([
530531
html.H3('Test content 1')
531532
], id='test-tab-1')
532-
elif(tab == 'tab-2'):
533+
elif tab == 'tab-2':
533534
return html.Div([
534535
html.H3('Test content 2')
535536
], id='test-tab-2')
@@ -565,7 +566,6 @@ def test_tabs_render_without_selected(self):
565566
{'id': 'two', 'value': 2},
566567
]
567568

568-
569569
menu = html.Div([
570570
html.Div('one', id='one'),
571571
html.Div('two', id='two')
@@ -583,7 +583,6 @@ def test_tabs_render_without_selected(self):
583583
])
584584
], id='tabs-two', style={'display': 'none'})
585585

586-
587586
app.layout = html.Div([
588587
menu,
589588
tabs_one,
@@ -593,7 +592,7 @@ def test_tabs_render_without_selected(self):
593592
for i in ('one', 'two'):
594593

595594
@app.callback(Output('tabs-{}'.format(i), 'style'),
596-
[Input(i, 'n_clicks')])
595+
[Input(i, 'n_clicks')])
597596
def on_click(n_clicks):
598597
if n_clicks is None:
599598
raise PreventUpdate
@@ -602,18 +601,17 @@ def on_click(n_clicks):
602601
return {'display': 'block'}
603602
return {'display': 'none'}
604603

605-
606604
@app.callback(Output('graph-{}'.format(i), 'figure'),
607-
[Input(i, 'n_clicks')])
605+
[Input(i, 'n_clicks')])
608606
def on_click(n_clicks):
609607
if n_clicks is None:
610608
raise PreventUpdate
611609

612610
return {
613611
'data': [
614612
{
615-
'x': [1,2,3,4],
616-
'y': [4,3,2,1]
613+
'x': [1, 2, 3, 4],
614+
'y': [4, 3, 2, 1]
617615
}
618616
]
619617
}
@@ -655,9 +653,8 @@ def test_tabs_without_value(self):
655653
html.Div(id='tabs-content')
656654
])
657655

658-
659656
@app.callback(Output('tabs-content', 'children'),
660-
[Input('tabs-without-value', 'value')])
657+
[Input('tabs-without-value', 'value')])
661658
def render_content(tab):
662659
if tab == 'tab-1':
663660
return html.H3('Default selected Tab content 1')
@@ -682,7 +679,7 @@ def test_graph_does_not_resize_in_tabs(self):
682679
])
683680

684681
@app.callback(Output('tabs-content-example', 'children'),
685-
[Input('tabs-example', 'value')])
682+
[Input('tabs-example', 'value')])
686683
def render_content(tab):
687684
if tab == 'tab-1-example':
688685
return html.Div([
@@ -744,7 +741,6 @@ def render_content(tab):
744741

745742
self.snapshot("Tabs with Graph - clicked tab 1 (graph should not resize)")
746743

747-
748744
def test_location_link(self):
749745
app = dash.Dash(__name__)
750746

@@ -889,7 +885,7 @@ def test_link_scroll(self):
889885
call_count = Value('i', 0)
890886

891887
@app.callback(Output('page-content', 'children'),
892-
[Input('test-url', 'pathname')])
888+
[Input('test-url', 'pathname')])
893889
def display_page(pathname):
894890
call_count.value = call_count.value + 1
895891
return 'You are on page {}'.format(pathname)
@@ -898,7 +894,7 @@ def display_page(pathname):
898894

899895
time.sleep(2)
900896

901-
#callback is called twice when defined
897+
# callback is called twice when defined
902898
self.assertEqual(
903899
call_count.value,
904900
2
@@ -917,11 +913,11 @@ def display_page(pathname):
917913
self.wait_for_text_to_equal(
918914
'#page-content', 'You are on page /test-link')
919915

920-
#test if rendered Link's <a> tag has a href attribute
916+
# test if rendered Link's <a> tag has a href attribute
921917
link_href = test_link.get_attribute("href")
922918
self.assertEqual(link_href, 'http://localhost:8050/test-link')
923919

924-
#test if callback is only fired once (offset of 2)
920+
# test if callback is only fired once (offset of 2)
925921
self.assertEqual(
926922
call_count.value,
927923
3
@@ -1030,7 +1026,7 @@ def test_datepickerrange_updatemodes(self):
10301026
@app.callback(
10311027
dash.dependencies.Output('date-picker-range-output', 'children'),
10321028
[dash.dependencies.Input('date-picker-range', 'start_date'),
1033-
dash.dependencies.Input('date-picker-range', 'end_date')])
1029+
dash.dependencies.Input('date-picker-range', 'end_date')])
10341030
def update_output(start_date, end_date):
10351031
return '{} - {}'.format(start_date, end_date)
10361032

@@ -1062,7 +1058,7 @@ def test_interval(self):
10621058
])
10631059

10641060
@app.callback(Output('output', 'children'),
1065-
[Input('interval', 'n_intervals')])
1061+
[Input('interval', 'n_intervals')])
10661062
def update_text(n):
10671063
return "{}".format(n)
10681064

@@ -1093,7 +1089,7 @@ def test_if_interval_can_be_restarted(self):
10931089
@app.callback(
10941090
Output('interval', 'max_intervals'),
10951091
[Input('start', 'n_clicks_timestamp'),
1096-
Input('stop', 'n_clicks_timestamp')])
1092+
Input('stop', 'n_clicks_timestamp')])
10971093
def start_stop(start, stop):
10981094
if start < stop:
10991095
return 0
@@ -1494,9 +1490,9 @@ def update_output(input, state):
14941490
return 'input="{}", state="{}"'.format(input, state)
14951491

14961492
self.startServer(app)
1497-
output = lambda: self.driver.find_element_by_id('output')
1498-
input = lambda: self.driver.find_element_by_id('input')
1499-
state = lambda: self.driver.find_element_by_id('state')
1493+
output = lambda: self.driver.find_element_by_id('output') # noqa: E731
1494+
input = lambda: self.driver.find_element_by_id('input') # noqa: E731
1495+
state = lambda: self.driver.find_element_by_id('state') # noqa: E731
15001496

15011497
# callback gets called with initial input
15021498
wait_for(lambda: call_count.value == 1)
@@ -1559,7 +1555,6 @@ def update_output(value):
15591555
call_count.value,
15601556
# an initial call to retrieve the first value
15611557
1 +
1562-
# one for each hello world character
1558+
# one for each hello world character # noqa: W504
15631559
len('hello world')
15641560
)
1565-

0 commit comments

Comments
 (0)