-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from enthought/fix-issue-67-ctraits
Check for property deletion (#67)
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Unit tests to ensure that we can call reset_traits/delete on a | ||
property trait (regression tests for Github issue #67). | ||
""" | ||
|
||
from traits import _py2to3 | ||
from traits.api import Any, HasTraits, Int, Property, TraitError | ||
from traits.testing.unittest_tools import unittest | ||
|
||
|
||
class E(HasTraits): | ||
|
||
a = Property(Any) | ||
|
||
b = Property(Int) | ||
|
||
|
||
class TestPropertyDelete(unittest.TestCase): | ||
|
||
def test_property_delete(self): | ||
e = E() | ||
with self.assertRaises(TraitError): | ||
del e.a | ||
with self.assertRaises(TraitError): | ||
del e.b | ||
|
||
def test_property_reset_traits(self): | ||
e = E() | ||
unresetable = e.reset_traits() | ||
_py2to3.assertCountEqual(self, unresetable, ['a', 'b']) |