Debian Codegraph @

hypothesis-python/tests/cover/test_composite_kwonlyargs.py

raw
1 # This file is part of Hypothesis, which may be found at
2 # https://github.com/HypothesisWorks/hypothesis/
3 #
4 # Copyright the Hypothesis Authors.
5 # Individual contributors are listed in AUTHORS.rst and the git log.
6 #
7 # This Source Code Form is subject to the terms of the Mozilla Public License,
8 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
9 # obtain one at https://mozilla.org/MPL/2.0/.
10
11 from hypothesis import given, strategies as st
12
13 # Tests that convert_keyword_arguments in reflection.py can handle
14 # composites that only have keyword-only arguments.
15 # See https://github.com/HypothesisWorks/hypothesis/issues/1999
16
17
18 @st.composite
19 def kwonlyargs_composites(draw, *, kwarg1=None):
20 return draw(st.fixed_dictionaries({"kwarg1": st.just(kwarg1), "i": st.integers()}))
21
22
23 @given(
24 st.lists(
25 st.one_of(kwonlyargs_composites(kwarg1="test")), unique_by=lambda x: x["i"]
26 )
27 )
28 def test_composite_with_keyword_only_args(a):
29 pass