Merge pull request #5 from jamielennox/from-positional
Use from positional import positional syntax
This commit is contained in:
commit
0090b9b776
@ -15,22 +15,22 @@ import logging
|
|||||||
import six
|
import six
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
import positional
|
from positional import positional
|
||||||
|
|
||||||
|
|
||||||
class TestPositional(testtools.TestCase):
|
class TestPositional(testtools.TestCase):
|
||||||
|
|
||||||
@positional.positional(1)
|
@positional(1)
|
||||||
def no_vars(self):
|
def no_vars(self):
|
||||||
# positional doesn't enforce anything here
|
# positional doesn't enforce anything here
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@positional.positional(3, positional.positional.EXCEPT)
|
@positional(3, positional.EXCEPT)
|
||||||
def mixed_except(self, arg, kwarg1=None, kwarg2=None):
|
def mixed_except(self, arg, kwarg1=None, kwarg2=None):
|
||||||
# self, arg, and kwarg1 may be passed positionally
|
# self, arg, and kwarg1 may be passed positionally
|
||||||
return (arg, kwarg1, kwarg2)
|
return (arg, kwarg1, kwarg2)
|
||||||
|
|
||||||
@positional.positional(3, positional.positional.WARN)
|
@positional(3, positional.WARN)
|
||||||
def mixed_warn(self, arg, kwarg1=None, kwarg2=None):
|
def mixed_warn(self, arg, kwarg1=None, kwarg2=None):
|
||||||
# self, arg, and kwarg1 may be passed positionally, only a warning
|
# self, arg, and kwarg1 may be passed positionally, only a warning
|
||||||
# is emitted
|
# is emitted
|
||||||
@ -62,7 +62,7 @@ class TestPositional(testtools.TestCase):
|
|||||||
|
|
||||||
self.assertIn('takes at most 3 positional', logger_message.getvalue())
|
self.assertIn('takes at most 3 positional', logger_message.getvalue())
|
||||||
|
|
||||||
@positional.positional(enforcement=positional.positional.EXCEPT)
|
@positional(enforcement=positional.EXCEPT)
|
||||||
def inspect_func(self, arg, kwarg=None):
|
def inspect_func(self, arg, kwarg=None):
|
||||||
return (arg, kwarg)
|
return (arg, kwarg)
|
||||||
|
|
||||||
@ -72,11 +72,11 @@ class TestPositional(testtools.TestCase):
|
|||||||
self.assertRaises(TypeError, self.inspect_func)
|
self.assertRaises(TypeError, self.inspect_func)
|
||||||
self.assertRaises(TypeError, self.inspect_func, 1, 2)
|
self.assertRaises(TypeError, self.inspect_func, 1, 2)
|
||||||
|
|
||||||
@positional.positional.classmethod(1)
|
@positional.classmethod(1)
|
||||||
def class_method(cls, a, b):
|
def class_method(cls, a, b):
|
||||||
return (cls, a, b)
|
return (cls, a, b)
|
||||||
|
|
||||||
@positional.positional.method(1)
|
@positional.method(1)
|
||||||
def normal_method(self, a, b):
|
def normal_method(self, a, b):
|
||||||
self.assertIsInstance(self, TestPositional)
|
self.assertIsInstance(self, TestPositional)
|
||||||
return (self, a, b)
|
return (self, a, b)
|
||||||
|
Loading…
Reference in New Issue
Block a user