def test_lambda_list_keywords_kwonly():
 kwonly_demo = u'(fn [&kwonly a [b 2]] (print a b))'
 if PY3:
  code = can_compile(kwonly_demo)
  for (i, kwonlyarg_name) in enumerate((u'a', u'b')):
   assert (kwonlyarg_name == code.body[0].args.kwonlyargs[i].arg)
  assert (code.body[0].args.kw_defaults[0] is None)
  assert (code.body[0].args.kw_defaults[1].n == 2)
 else:
  exception = cant_compile(kwonly_demo)
  assert isinstance(exception, HyTypeError)
  (message,) = exception.args
  assert (message == u'keyword-only arguments are only available under Python 3')

def test_lambda_list_keywords_kwonly ( ) : kwonly_demo = u'(fn [&kwonly a [b 2]] (print a b))' if PY3 : code = can_compile ( kwonly_demo ) for ( i , kwonlyarg_name ) in enumerate ( ( u'a' , u'b' ) ) : assert ( kwonlyarg_name == code . body [ 0 ] . args . kwonlyargs [ i ] . arg ) assert ( code . body [ 0 ] . args . kw_defaults [ 0 ] is None ) assert ( code . body [ 0 ] . args . kw_defaults [ 1 ] . n == 2 ) else : exception = cant_compile ( kwonly_demo ) assert isinstance ( exception , HyTypeError ) ( message , ) = exception . args assert ( message == u'keyword-only arguments are only available under Python 3' )
ensure we can compile functions with &kwonly if were on python 3 .