How to use has_varargs method in hypothesis

Best Python code snippet using hypothesis

test_inspect_args.py

Source:test_inspect_args.py Github

copy

Full Screen

...202 assert is_partial_args(f, (None,), {})203 assert is_partial_args(f, (), {'func': None})204 assert is_partial_args(f, (None,), {'func': None}) is False205def test_has_unknown_args():206 assert has_varargs(1) is False207 assert has_varargs(map)208 assert has_varargs(make_func('')) is False209 assert has_varargs(make_func('x, y, z')) is False210 assert has_varargs(make_func('*args'))211 assert has_varargs(make_func('**kwargs')) is False212 assert has_varargs(make_func('x, y, *args, **kwargs'))213 assert has_varargs(make_func('x, y, z=1')) is False214 assert has_varargs(make_func('x, y, z=1, **kwargs')) is False215 if PY3:216 f = make_func('*args')217 f.__signature__ = 34218 assert has_varargs(f) is False219 class RaisesValueError(object):220 def __call__(self):221 pass222 @property223 def __signature__(self):224 raise ValueError('Testing Python 3.4')225 f = RaisesValueError()226 assert has_varargs(f) is None227def test_num_required_args():228 assert num_required_args(lambda: None) == 0229 assert num_required_args(lambda x: None) == 1230 assert num_required_args(lambda x, *args: None) == 1231 assert num_required_args(lambda x, **kwargs: None) == 1232 assert num_required_args(lambda x, y, *args, **kwargs: None) == 2233 assert num_required_args(map) == 2234 assert num_required_args(dict) is None235def test_has_keywords():236 assert has_keywords(lambda: None) is False237 assert has_keywords(lambda x: None) is False238 assert has_keywords(lambda x=1: None)239 assert has_keywords(lambda **kwargs: None)240 assert has_keywords(int)241 assert has_keywords(sorted)242 assert has_keywords(max)243 assert has_keywords(map) is False244 assert has_keywords(bytearray) is None245def test_has_varargs():246 assert has_varargs(lambda: None) is False247 assert has_varargs(lambda *args: None)248 assert has_varargs(lambda **kwargs: None) is False249 assert has_varargs(map)250 if PY3:251 assert has_varargs(max) is None252def test_is_arity():253 assert is_arity(0, lambda: None)254 assert is_arity(1, lambda: None) is False255 assert is_arity(1, lambda x: None)256 assert is_arity(3, lambda x, y, z: None)257 assert is_arity(1, lambda x, *args: None) is False258 assert is_arity(1, lambda x, **kwargs: None) is False259 assert is_arity(1, all)260 assert is_arity(2, map) is False261 assert is_arity(2, range) is None262def test_introspect_curry_valid_py3(check_valid=is_valid_args, incomplete=False):263 if not PY3:264 return265 orig_check_valid = check_valid266 check_valid = lambda _func, *args, **kwargs: orig_check_valid(_func, args, kwargs)267 f = toolz.curry(make_func('x, y, z=0'))268 assert check_valid(f)269 assert check_valid(f, 1)270 assert check_valid(f, 1, 2)271 assert check_valid(f, 1, 2, 3)272 assert check_valid(f, 1, 2, 3, 4) is False273 assert check_valid(f, invalid_keyword=True) is False274 assert check_valid(f(1))275 assert check_valid(f(1), 2)276 assert check_valid(f(1), 2, 3)277 assert check_valid(f(1), 2, 3, 4) is False278 assert check_valid(f(1), x=2) is False279 assert check_valid(f(1), y=2)280 assert check_valid(f(x=1), 2) is False281 assert check_valid(f(x=1), y=2)282 assert check_valid(f(y=2), 1)283 assert check_valid(f(y=2), 1, z=3)284 assert check_valid(f(y=2), 1, 3) is False285 f = toolz.curry(make_func('x, y, z=0'), 1, x=1)286 assert check_valid(f) is False287 assert check_valid(f, z=3) is False288 f = toolz.curry(make_func('x, y, *args, z'))289 assert check_valid(f)290 assert check_valid(f, 0)291 assert check_valid(f(1), 0)292 assert check_valid(f(1, 2), 0)293 assert check_valid(f(1, 2, 3), 0)294 assert check_valid(f(1, 2, 3, 4), 0)295 assert check_valid(f(1, 2, 3, 4), z=4)296 assert check_valid(f(x=1))297 assert check_valid(f(x=1), 1) is False298 assert check_valid(f(x=1), y=2)299def test_introspect_curry_partial_py3():300 test_introspect_curry_valid_py3(check_valid=is_partial_args, incomplete=True)301def test_introspect_curry_py3():302 if not PY3:303 return304 f = toolz.curry(make_func(''))305 assert num_required_args(f) == 0306 assert is_arity(0, f)307 assert has_varargs(f) is False308 assert has_keywords(f) is False309 f = toolz.curry(make_func('x'))310 assert num_required_args(f) == 0311 assert is_arity(0, f) is False312 assert is_arity(1, f) is False313 assert has_varargs(f) is False314 assert has_keywords(f) # A side-effect of being curried315 f = toolz.curry(make_func('x, y, z=0'))316 assert num_required_args(f) == 0317 assert is_arity(0, f) is False318 assert is_arity(1, f) is False319 assert is_arity(2, f) is False320 assert is_arity(3, f) is False321 assert has_varargs(f) is False322 assert has_keywords(f)323 f = toolz.curry(make_func('*args, **kwargs'))324 assert num_required_args(f) == 0325 assert has_varargs(f)326 assert has_keywords(f)327def test_introspect_builtin_modules():328 mods = [builtins, functools, itertools, operator, toolz,329 toolz.functoolz, toolz.itertoolz, toolz.dicttoolz, toolz.recipes]330 blacklist = set()331 def add_blacklist(mod, attr):332 if hasattr(mod, attr):333 blacklist.add(getattr(mod, attr))334 add_blacklist(builtins, 'basestring')335 add_blacklist(builtins, 'NoneType')336 add_blacklist(builtins, '__metaclass__')337 add_blacklist(builtins, 'sequenceiterator')338 def is_missing(modname, name, func):339 if name.startswith('_') and not name.startswith('__'):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful