Skip to content

Commit

Permalink
Merge pull request #1 from enthought/deprecate-edit-additional-testing
Browse files Browse the repository at this point in the history
Augment and strengthen tests for deprecation of edit parameter
  • Loading branch information
avats-dev authored Sep 19, 2020
2 parents e553c4e + cea80d3 commit aaf0bbd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions traits/tests/test_configure_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import tempfile
import unittest
import unittest.mock as mock
import warnings

from traits.api import HasTraits, Int
from traits.testing.optional_dependencies import requires_traitsui, traitsui
Expand Down Expand Up @@ -130,13 +131,27 @@ def modify_model(*args, **kwargs):
def test_edit_when_false(self):
# Check for deprecation warning when *edit* is false.
model = Model()
with mock.patch.object(self.toolkit, "view_application"):
with mock.patch.object(self.toolkit, "view_application") as mock_view:
with self.assertWarns(DeprecationWarning):
model.configure_traits(edit=False)
mock_view.assert_not_called()

def test_edit_when_true(self):
# Check for deprecation warning when *edit* is false.
model = Model()
with mock.patch.object(self.toolkit, "view_application"):
with mock.patch.object(self.toolkit, "view_application") as mock_view:
mock_view.return_value = True
with self.assertWarns(DeprecationWarning):
model.configure_traits(edit=True)
self.assertEqual(len(mock_view.mock_calls), 1)

def test_edit_not_given(self):
# Normal case where the *edit* argument is not supplied.
model = Model()
with mock.patch.object(self.toolkit, "view_application") as mock_view:
mock_view.return_value = True
with warnings.catch_warnings(record=True) as captured_warnings:
warnings.simplefilter("always", DeprecationWarning)
model.configure_traits()
self.assertEqual(len(mock_view.mock_calls), 1)
self.assertEqual(len(captured_warnings), 0)

0 comments on commit aaf0bbd

Please sign in to comment.