Skip to content

Commit 6df68da

Browse files
committed
s/has_trait_value/trait_has_value
1 parent 4267eec commit 6df68da

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

traitlets/tests/test_traitlets.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -765,17 +765,17 @@ class A(HasTraits):
765765
self.assertTrue(a.has_trait('f'))
766766
self.assertFalse(a.has_trait('g'))
767767

768-
def test_has_trait_value(self):
768+
def test_trait_has_value(self):
769769
class A(HasTraits):
770770
i = Int()
771771
f = Float()
772772
a = A()
773-
self.assertFalse(a.has_trait_value('f'))
774-
self.assertFalse(a.has_trait_value('g'))
773+
self.assertFalse(a.trait_has_value('f'))
774+
self.assertFalse(a.trait_has_value('g'))
775775
a.i = 1
776776
a.f
777-
self.assertTrue(a.has_trait_value('i'))
778-
self.assertTrue(a.has_trait_value('f'))
777+
self.assertTrue(a.trait_has_value('i'))
778+
self.assertTrue(a.trait_has_value('f'))
779779

780780
def test_trait_metadata_deprecated(self):
781781
with expected_warnings(['metadata should be set using the \.tag\(\) method']):

traitlets/traitlets.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ def has_trait(self, name):
14381438
"""Returns True if the object has a trait with the specified name."""
14391439
return isinstance(getattr(self.__class__, name, None), TraitType)
14401440

1441-
def has_trait_value(self, name):
1441+
def trait_has_value(self, name):
14421442
"""Returns True if the specified trait has a value.
14431443
14441444
This will return false even if ``getattr`` would return a
@@ -1453,9 +1453,9 @@ class MyClass(HasTraits):
14531453
i = Int()
14541454
14551455
mc = MyClass()
1456-
assert not mc.has_trait_value("i")
1456+
assert not mc.trait_has_value("i")
14571457
mc.i # generates a default value
1458-
assert mc.has_trait_value("i")
1458+
assert mc.trait_has_value("i")
14591459
"""
14601460
return name in self._trait_values
14611461

0 commit comments

Comments
 (0)