Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8a1d1ce

Browse filesBrowse files
committed
Add a TestCase to stash/restore local creds.
Otherwise, it’s pretty easy to munge them if tests change them!
1 parent 95ee2e4 commit 8a1d1ce
Copy full SHA for 8a1d1ce

File tree

Expand file treeCollapse file tree

1 file changed

+36
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+36
-0
lines changed

‎plotly/tests/utils.py

Copy file name to clipboardExpand all lines: plotly/tests/utils.py
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1+
import json
12
from numbers import Number as Num
3+
from unittest import TestCase
4+
5+
from plotly.tools import CREDENTIALS_FILE, CONFIG_FILE, _file_permissions
6+
7+
8+
class PlotlyTestCase(TestCase):
9+
10+
# parent test case to assist with clean up of local credentials/config
11+
12+
def __init__(self, **kwargs):
13+
self._credentials = None
14+
self._config = None
15+
super(PlotlyTestCase, self).__init__(**kwargs)
16+
17+
def setUp(self):
18+
self.stash_credentials_and_config()
19+
20+
def tearDown(self):
21+
self.restore_credentials_and_config()
22+
23+
def stash_credentials_and_config(self):
24+
if _file_permissions:
25+
with open(CREDENTIALS_FILE, 'r') as f:
26+
self._credentials = json.load(f)
27+
with open(CONFIG_FILE, 'r') as f:
28+
self._config = json.load(f)
29+
30+
def restore_credentials_and_config(self):
31+
if _file_permissions:
32+
if self._credentials is not None:
33+
with open(CREDENTIALS_FILE, 'w') as f:
34+
json.dump(self._credentials, f)
35+
if self._config is not None:
36+
with open(CONFIG_FILE, 'w') as f:
37+
json.load(self._config, f)
238

339

440
def compare_dict(dict1, dict2, equivalent=True, msg='', tol=10e-8):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.