##// END OF EJS Templates
Merge pull request #3205 from minrk/traitletsargs...
Brian E. Granger -
r10374:46e23e9f merge
parent child Browse files
Show More
@@ -411,6 +411,18 b' class TestHasTraits(TestCase):'
411 self.assertEqual(a.i, 1)
411 self.assertEqual(a.i, 1)
412 self.assertEqual(a.x, 10.0)
412 self.assertEqual(a.x, 10.0)
413
413
414 def test_positional_args(self):
415 class A(HasTraits):
416 i = Int(0)
417 def __init__(self, i):
418 super(A, self).__init__()
419 self.i = i
420
421 a = A(5)
422 self.assertEqual(a.i, 5)
423 # should raise TypeError if no positional arg given
424 self.assertRaises(TypeError, A)
425
414 #-----------------------------------------------------------------------------
426 #-----------------------------------------------------------------------------
415 # Tests for specific trait types
427 # Tests for specific trait types
416 #-----------------------------------------------------------------------------
428 #-----------------------------------------------------------------------------
@@ -398,7 +398,7 b' class HasTraits(object):'
398
398
399 __metaclass__ = MetaHasTraits
399 __metaclass__ = MetaHasTraits
400
400
401 def __new__(cls, **kw):
401 def __new__(cls, *args, **kw):
402 # This is needed because in Python 2.6 object.__new__ only accepts
402 # This is needed because in Python 2.6 object.__new__ only accepts
403 # the cls argument.
403 # the cls argument.
404 new_meth = super(HasTraits, cls).__new__
404 new_meth = super(HasTraits, cls).__new__
@@ -425,7 +425,7 b' class HasTraits(object):'
425
425
426 return inst
426 return inst
427
427
428 def __init__(self, **kw):
428 def __init__(self, *args, **kw):
429 # Allow trait values to be set using keyword arguments.
429 # Allow trait values to be set using keyword arguments.
430 # We need to use setattr for this to trigger validation and
430 # We need to use setattr for this to trigger validation and
431 # notifications.
431 # notifications.
General Comments 0
You need to be logged in to leave comments. Login now