Did I find the right examples for you? yes no

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)

        def valid_unsigned_short(val):
    try:
        struct.pack("H", int(val))
    except struct.error:
        raise NotValid("unsigned short")
    except ValueError:
        raise NotValid("unsigned short")
        
    return True
        


src/p/y/pysaml2-2.0.0/tests/test_13_validate.py   pysaml2(Download)
from saml2 import md
from saml2.validate import valid_duration, MustValueError
from saml2.validate import valid_unsigned_short
from saml2.validate import valid_non_negative_integer
from saml2.validate import valid_string
def test_unsigned_short():
    assert valid_unsigned_short("1234")
 
    raises( NotValid, ' valid_unsigned_short("-1234")')
    raises( NotValid, ' valid_unsigned_short("1234567890")')

src/p/y/pysaml2-HEAD/tests/test_13_validate.py   pysaml2(Download)
from saml2 import md
from saml2.validate import valid_duration, MustValueError
from saml2.validate import valid_unsigned_short
from saml2.validate import valid_non_negative_integer
from saml2.validate import valid_string
def test_unsigned_short():
    assert valid_unsigned_short("1234")
 
    raises(NotValid, ' valid_unsigned_short("-1234")')
    raises(NotValid, ' valid_unsigned_short("1234567890")')