Show More
@@ -1088,6 +1088,13 b' def test_dict_assignment():' | |||||
1088 | nt.assert_equal(d, c.value) |
|
1088 | nt.assert_equal(d, c.value) | |
1089 | nt.assert_true(c.value is d) |
|
1089 | nt.assert_true(c.value is d) | |
1090 |
|
1090 | |||
|
1091 | def test_dict_default_value(): | |||
|
1092 | """Check that the `{}` default value of the Dict traitlet constructor is | |||
|
1093 | actually copied.""" | |||
|
1094 | ||||
|
1095 | d1, d2 = Dict(), Dict() | |||
|
1096 | nt.assert_false(d1.get_default_value() is d2.get_default_value()) | |||
|
1097 | ||||
1091 | class TestLink(TestCase): |
|
1098 | class TestLink(TestCase): | |
1092 | def test_connect_same(self): |
|
1099 | def test_connect_same(self): | |
1093 | """Verify two traitlets of the same type can be linked together using link.""" |
|
1100 | """Verify two traitlets of the same type can be linked together using link.""" |
@@ -1635,14 +1635,14 b' class Tuple(Container):' | |||||
1635 | class Dict(Instance): |
|
1635 | class Dict(Instance): | |
1636 | """An instance of a Python dict.""" |
|
1636 | """An instance of a Python dict.""" | |
1637 |
|
1637 | |||
1638 |
def __init__(self, default_value= |
|
1638 | def __init__(self, default_value={}, allow_none=True, **metadata): | |
1639 | """Create a dict trait type from a dict. |
|
1639 | """Create a dict trait type from a dict. | |
1640 |
|
1640 | |||
1641 | The default value is created by doing ``dict(default_value)``, |
|
1641 | The default value is created by doing ``dict(default_value)``, | |
1642 | which creates a copy of the ``default_value``. |
|
1642 | which creates a copy of the ``default_value``. | |
1643 | """ |
|
1643 | """ | |
1644 | if default_value is None: |
|
1644 | if default_value is None: | |
1645 |
args = |
|
1645 | args = None | |
1646 | elif isinstance(default_value, dict): |
|
1646 | elif isinstance(default_value, dict): | |
1647 | args = (default_value,) |
|
1647 | args = (default_value,) | |
1648 | elif isinstance(default_value, SequenceTypes): |
|
1648 | elif isinstance(default_value, SequenceTypes): | |
@@ -1657,15 +1657,15 b' class Dict(Instance):' | |||||
1657 | class EventfulDict(Instance): |
|
1657 | class EventfulDict(Instance): | |
1658 | """An instance of an EventfulDict.""" |
|
1658 | """An instance of an EventfulDict.""" | |
1659 |
|
1659 | |||
1660 |
def __init__(self, default_value= |
|
1660 | def __init__(self, default_value={}, allow_none=True, **metadata): | |
1661 | """Create a EventfulDict trait type from a dict. |
|
1661 | """Create a EventfulDict trait type from a dict. | |
1662 |
|
1662 | |||
1663 |
The default value is created by doing |
|
1663 | The default value is created by doing | |
1664 |
``eventful.EvenfulDict(default_value)``, which creates a copy of the |
|
1664 | ``eventful.EvenfulDict(default_value)``, which creates a copy of the | |
1665 | ``default_value``. |
|
1665 | ``default_value``. | |
1666 | """ |
|
1666 | """ | |
1667 | if default_value is None: |
|
1667 | if default_value is None: | |
1668 |
args = |
|
1668 | args = None | |
1669 | elif isinstance(default_value, dict): |
|
1669 | elif isinstance(default_value, dict): | |
1670 | args = (default_value,) |
|
1670 | args = (default_value,) | |
1671 | elif isinstance(default_value, SequenceTypes): |
|
1671 | elif isinstance(default_value, SequenceTypes): |
General Comments 0
You need to be logged in to leave comments.
Login now