-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up test output #553
Clean up test output #553
Changes from 3 commits
c3e7080
b299830
94efddf
75ebfbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,15 +89,15 @@ def test_subclass_extension_category(self): | |
Seems like the declaration of the subclass (BasePlusPlus) should fail. | ||
""" | ||
try: | ||
x = self.base.pp | ||
self.base.pp | ||
self.fail( | ||
msg="base.pp should have thrown AttributeError " | ||
"as Category subclassing is not supported." | ||
) | ||
except AttributeError: | ||
pass | ||
|
||
basepp = BasePlusPlus() | ||
BasePlusPlus() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im guessing that this too is a test where we instantiate the object and we expect to see/not-see errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. |
||
return | ||
|
||
def test_subclass_instance_category(self): | ||
|
@@ -130,10 +130,13 @@ def test_subclasses_dont_modify_category_base_class(self): | |
class A(HasTraits): | ||
a = Str() | ||
|
||
class B(Category, A): | ||
b = Str() | ||
with warnings.catch_warnings(record=True): | ||
warnings.simplefilter("always", DeprecationWarning) | ||
|
||
class B(Category, A): | ||
b = Str() | ||
|
||
class C(Category, A): | ||
c = Str() | ||
class C(Category, A): | ||
c = Str() | ||
|
||
self.assertEqual(Category.__class_traits__, {}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
|
||
# Standard library imports. | ||
import unittest | ||
import warnings | ||
|
||
# Enthought library imports. | ||
from traits.adaptation.api import reset_global_adaptation_manager | ||
|
@@ -392,7 +393,7 @@ class Foo(HasTraits): | |
class Bar(HasTraits): | ||
foo = Instance(IFoo) | ||
|
||
b = Bar(foo=Foo()) | ||
Bar(foo=Foo()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im guessing this too is a test where we simply instantiate the object and expect to see/not see errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this was a drive-by fix to eliminate a |
||
|
||
return | ||
|
||
|
@@ -407,9 +408,18 @@ class Foo(HasTraits): | |
pass | ||
|
||
f = Foo() | ||
self.assertEqual(f, IFoo(f)) | ||
|
||
return | ||
# Adaptation via direct instantiation of interfaces is deprecated, so | ||
# catch the warning to keep the test run output clean. | ||
with warnings.catch_warnings(record=True) as warn_msgs: | ||
warnings.simplefilter("always", DeprecationWarning) | ||
self.assertEqual(f, IFoo(f)) | ||
|
||
self.assertEqual(len(warn_msgs), 1) | ||
warn_msg = warn_msgs[0] | ||
self.assertIn( | ||
'use "adapt(adaptee, protocol)" instead', str(warn_msg.message)) | ||
self.assertIn("test_interface_checker", warn_msg.filename) | ||
|
||
def test_adaptation(self): | ||
""" adaptation """ | ||
|
@@ -428,9 +438,17 @@ class FooToIFooAdapter(Adapter): | |
|
||
f = Foo() | ||
|
||
# Make sure adaptation works. | ||
i_foo = IFoo(f) | ||
# Make sure adaptation works. Adaptation via direct instantiation of | ||
# Interface classes is deprecated, so suppress the warning. | ||
with warnings.catch_warnings(record=True) as warn_msgs: | ||
warnings.simplefilter("always", DeprecationWarning) | ||
i_foo = IFoo(f) | ||
|
||
self.assertNotEqual(None, i_foo) | ||
self.assertEqual(FooToIFooAdapter, type(i_foo)) | ||
return | ||
|
||
self.assertEqual(len(warn_msgs), 1) | ||
warn_msg = warn_msgs[0] | ||
self.assertIn( | ||
'use "adapt(adaptee, protocol)" instead', str(warn_msg.message)) | ||
self.assertIn("test_interface_checker", warn_msg.filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove the print but keep the call to
repr
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the effect of the test. It's (indirectly) testing that the
repr
doesn't fail, so I wanted to keep that test.