Skip to content

Commit a3aceb7

Browse files
authored
Merge pull request #100 from highcharts-for-python/develop
PR for v.1.3.7
2 parents fafd230 + 7ff526b commit a3aceb7

File tree

6 files changed

+66
-4
lines changed

6 files changed

+66
-4
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11

2+
Release 1.3.7
3+
=========================================
4+
5+
* **BUGFIX:** Fixed bug in ``HighchartsMeta.copy()`` (#98).
6+
* **BUGFIX:** Fixed bug in data point serialization to primitive array.
7+
8+
---------------------
9+
210
Release 1.3.6
311
=========================================
412

highcharts_core/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.6'
1+
__version__ = '1.3.7'

highcharts_core/js_literal_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def serialize_to_js_literal(item, encoding = 'utf-8') -> Optional[str]:
2525
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
2626
"""
2727
if checkers.is_iterable(item, forbid_literals = (str, bytes, dict, UserDict)):
28-
requires_js_objects = all([getattr(x, 'requires_js_object', True)
28+
requires_js_objects = any([getattr(x, 'requires_js_object', True)
2929
for x in item])
3030
if requires_js_objects:
3131
return [serialize_to_js_literal(x, encoding = encoding)

highcharts_core/metaclasses.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,14 @@ def _copy_dict_key(cls,
664664
665665
:returns: The value that should be placed in ``other`` for ``key``.
666666
"""
667+
if not isinstance(original, (dict, UserDict)):
668+
return original
669+
667670
original_value = original[key]
668-
other_value = other.get(key, None)
671+
if other is None:
672+
other_value = None
673+
else:
674+
other_value = other.get(key, None)
669675

670676
if isinstance(original_value, (dict, UserDict)):
671677
new_value = {}

tests/options/series/data/test_base.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for ``highcharts.no_data``."""
22

33
import pytest
4+
from typing import List
45

56
from json.decoder import JSONDecodeError
67

@@ -17,13 +18,38 @@ class NonAbstractDataBase(DataBase):
1718
def from_array(cls, value):
1819
pass
1920

21+
def _get_props_from_array(self) -> List[str]:
22+
"""Returns a list of the property names that can be set using the
23+
:meth:`.from_array() <highcharts_core.options.series.data.base.DataBase.from_array>`
24+
method.
25+
26+
:rtype: :class:`list <python:list>` of :class:`str <python:str>`
27+
"""
28+
return ['fromArrayProp1', 'fromArrayProp2']
29+
30+
31+
2032
cls = NonAbstractDataBase
2133

2234

2335
class RequiringJSObject(NonAbstractDataBase):
2436
def _to_untrimmed_dict(self):
2537
return {'someKey': 123}
2638

39+
class NotRequiringJSObject(NonAbstractDataBase):
40+
def _to_untrimmed_dict(self):
41+
return {
42+
'fromArrayProp1': 456,
43+
'fromArrayProp2': 789
44+
}
45+
46+
47+
class RequiringJSObject2(NonAbstractDataBase):
48+
def _to_untrimmed_dict(self):
49+
return {'someKey': 123,
50+
'fromArrayProp1': 456,
51+
'fromArrayProp2': 789}
52+
2753

2854
STANDARD_PARAMS = [
2955
({}, None),
@@ -102,8 +128,10 @@ def test_from_js_literal(input_files, filename, as_file, error):
102128

103129
@pytest.mark.parametrize('cls, expected', [
104130
(NonAbstractDataBase, False),
131+
(NotRequiringJSObject, False),
105132
(RequiringJSObject, True),
106-
133+
(RequiringJSObject2, True)
134+
107135
])
108136
def test_requires_js_object(cls, expected):
109137
obj = cls()

tests/test_metaclasses.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,26 @@ def test_trim_iterable(untrimmed, expected_type, expected_length, error):
232232
with pytest.raises(error):
233233
result = TestClass.trim_iterable(untrimmed)
234234

235+
236+
@pytest.mark.parametrize('instance, error', [
237+
(test_class_instance, None),
238+
(test_class_trimmed_instance, None),
239+
(test_class_iterable, None),
240+
(test_class_none_iterable, None),
241+
])
242+
def test_copy(instance, error):
243+
if not error:
244+
result = instance.copy()
245+
assert result is not None
246+
assert isinstance(result, instance.__class__) is True
247+
result_as_dict = result.to_dict()
248+
instance_as_dict = instance.to_dict()
249+
assert checkers.are_dicts_equivalent(result_as_dict, instance_as_dict) is True
250+
else:
251+
with pytest.raises(error):
252+
result = instance.copy()
253+
254+
235255
"""
236256
@pytest.mark.parametrize('error', [
237257
(None),

0 commit comments

Comments
 (0)