Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 845b8e2

Browse files
committed
Fix test_core tests for v4 functionality
1 parent 43d4c95 commit 845b8e2

File tree

13 files changed

+40
-3168
lines changed

13 files changed

+40
-3168
lines changed

plotly/tests/test_core/test_figure_messages/test_add_traces.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ def test_add_trace(self):
3232
self.assertEqual(self.figure.data[-1].arrangement, 'snap')
3333

3434
# Check message
35-
new_uid = self.figure.data[-1].uid
3635
self.figure._send_addTraces_msg.assert_called_once_with(
37-
[{'type': 'sankey', 'arrangement': 'snap', 'uid': new_uid}])
36+
[{'type': 'sankey', 'arrangement': 'snap'}])
3837

3938
def test_add_traces(self):
4039

@@ -55,8 +54,6 @@ def test_add_traces(self):
5554
new_uid2 = self.figure.data[-1].uid
5655
self.figure._send_addTraces_msg.assert_called_once_with(
5756
[{'type': 'sankey',
58-
'arrangement': 'snap',
59-
'uid': new_uid1},
57+
'arrangement': 'snap'},
6058
{'type': 'histogram2dcontour',
61-
'line': {'color': 'cyan'},
62-
'uid': new_uid2}])
59+
'line': {'color': 'cyan'}}])

plotly/tests/test_core/test_graph_objs/test_figure.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
from unittest import TestCase
44

55
import plotly.graph_objs as go
6+
import plotly.io as pio
67

78

89
class FigureTest(TestCase):
910

11+
def setUp(self):
12+
pio.templates.default = None
13+
14+
def tearDown(self):
15+
pio.templates.default = 'plotly'
16+
1017
def test_instantiation(self):
1118

1219
native_figure = {

plotly/tests/test_core/test_graph_objs/test_figure_properties.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from unittest import TestCase
22
import plotly.graph_objs as go
33
from nose.tools import raises
4-
4+
import plotly.io as pio
55

66
class TestFigureProperties(TestCase):
77

88
def setUp(self):
9+
# Disable default template
10+
pio.templates.default = None
11+
912
# Construct initial scatter object
1013
self.figure = go.Figure(data=[go.Scatter(y=[3, 2, 1],
1114
marker={'color': 'green'})],
@@ -14,6 +17,10 @@ def setUp(self):
1417
layout={'yaxis':
1518
{'title': 'f1'}})])
1619

20+
def tearDown(self):
21+
# Reenable default template
22+
pio.templates.default = 'plotly'
23+
1724
def test_attr_access(self):
1825
scatt_uid = self.figure.data[0].uid
1926
self.assertEqual(self.figure.data,
@@ -174,8 +181,6 @@ def test_update_data_empty(self):
174181

175182
# Compute expected figure dict (pop uids for comparison)
176183
result = figure.to_dict()
177-
del result['data'][0]['uid']
178-
del result['data'][1]['uid']
179184

180185
# Perform comparison
181186
self.assertEqual(result, expected)

plotly/tests/test_core/test_graph_objs/test_layout_subplots.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest import TestCase
22
import plotly.graph_objs as go
33
from nose.tools import raises
4+
import plotly.io as pio
45

56

67
class TestLayoutSubplots(TestCase):
@@ -9,6 +10,11 @@ def setUp(self):
910
# Construct initial scatter object
1011
self.layout = go.Layout()
1112

13+
pio.templates.default = None
14+
15+
def tearDown(self):
16+
pio.templates.default = 'plotly'
17+
1218
def test_initial_access_subplots(self):
1319

1420
# It should be possible to access base subplots initially
@@ -217,7 +223,6 @@ def test_bug_1462(self):
217223

218224
layout_dict = {
219225
'grid': {'xaxes': ['x', 'x2'], 'yaxes': ['y']},
220-
# 'xaxis': {'title': 'total_bill'},
221226
'xaxis2': {'matches': 'x', 'title': {'text': 'total_bill'}}
222227
}
223228

plotly/tests/test_core/test_graph_objs/test_template.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ class TemplateTest(TestCase):
1515
def setUp(self):
1616
pio.templates['test_template'] = {
1717
'layout': {'font': {'family': 'Rockwell'}}}
18+
pio.templates.default = None
1819

1920
def tearDown(self):
2021
try:
2122
del pio.templates['test_template']
2223
except KeyError:
2324
pass
2425

26+
pio.templates.default = 'plotly'
27+
2528
# template graph_objs tests
2629
# -------------------------
2730
def test_starts_as_empty(self):
@@ -168,6 +171,12 @@ def test_template_iter(self):
168171

169172
class TestToTemplated(TestCase):
170173

174+
def setUp(self):
175+
pio.templates.default = None
176+
177+
def tearDown(self):
178+
pio.templates.default = 'plotly'
179+
171180
def test_move_layout_nested_properties(self):
172181
fig = go.Figure(layout={'font': {'family': 'Courier New'},
173182
'paper_bgcolor': 'yellow',

plotly/tests/test_core/test_graph_objs/test_to_ordered_dict.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
from unittest import TestCase
44
import plotly.graph_objs as go
55
from collections import OrderedDict
6+
import plotly.io as pio
67

78

89
class FigureTest(TestCase):
10+
def setUp(self):
11+
pio.templates.default = None
12+
13+
def tearDown(self):
14+
pio.templates.default = 'plotly'
915

1016
def test_to_ordered_dict(self):
1117

plotly/tests/test_core/test_graph_reference/test_graph_reference.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,15 @@
44
"""
55
from __future__ import absolute_import
66

7-
import os
87
from unittest import TestCase
98

10-
from nose.plugins.attrib import attr
11-
import json as _json
12-
139
from plotly import graph_reference as gr
14-
from plotly.api import v2
1510
from plotly.graph_reference import string_to_class_name, get_role
16-
from plotly.tests.utils import PlotlyTestCase
1711

1812
FAKE_API_DOMAIN = 'https://api.am.not.here.ly'
1913

2014

21-
#class TestGraphReferenceCaching(PlotlyTestCase):
22-
23-
# @attr('slow')
24-
# def test_default_schema_is_up_to_date(self):
25-
# response = v2.plot_schema.retrieve('')
26-
# schema = response.json()['schema']
27-
28-
# path = os.path.join('package_data', 'plot-schema.json')
29-
# s = resource_string('plotly', path).decode('utf-8')
30-
# default_schema = _json.loads(s)
31-
32-
# msg = (
33-
# 'The default, hard-coded plot schema we ship with pip is out of '
34-
# 'sync with the prod plot schema!\n'
35-
# 'Run `make update_default_schema` to fix it!'
36-
# )
37-
# self.assertEqual(schema, default_schema, msg=msg)
38-
39-
40-
class TestStringToClass(PlotlyTestCase):
15+
class TestStringToClass(TestCase):
4116

4217
def test_capitalize_first_letter(self):
4318

plotly/tests/test_core/test_tools/test_configuration.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

plotly/tests/test_core/test_tools/test_file_tools.py

Lines changed: 0 additions & 105 deletions
This file was deleted.

plotly/tests/test_core/test_tools/test_get_embed.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)