8000 Add get_config_defaults. · skytree-brian/plotly.py@db5fba7 · GitHub
[go: up one dir, main page]

Skip to content

Commit db5fba7

Browse files
committed
Add get_config_defaults.
1 parent f6531f9 commit db5fba7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import absolute_import
2+
3+
from unittest import TestCase
4+
5+
from plotly.tools import get_config_defaults, _FILE_CONTENT, CONFIG_FILE
6+
7+
8+
class TestGetConfigDefaults(TestCase):
9+
10+
def test_config_dict_is_equivalent_copy(self):
11+
12+
original = _FILE_CONTENT[CONFIG_FILE]
13+
copy = get_config_defaults()
14+
self.assertIsNot(copy, original)
15+
self.assertEqual(copy, original)

plotly/tools.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ def warning_on_one_line(message, category, filename, lineno,
8585
_file_permissions = False
8686

8787

88+
def get_config_defaults():
89+
"""
90+
Convenience function to check current settings against defaults.
91+
92+
Example:
93+
94+
if plotly_domain != get_config_defaults()['plotly_domain']:
95+
# do something
96+
97+
"""
98+
return dict(_FILE_CONTENT[CONFIG_FILE]) # performs a shallow copy
99+
100+
88101
def check_file_permissions():
89102
return _file_permissions
90103

0 commit comments

Comments
 (0)
0