1111import pycco .generate_index as generate_index
1212import pycco .main as p
1313from hypothesis import assume , example , given
14- from hypothesis .strategies import booleans , choices , lists , none , text
14+ from hypothesis .strategies import booleans , lists , none , text , sampled_from , data
1515from pycco .languages import supported_languages
1616
1717try :
2626FOO_FUNCTION = """def foo():\n return True"""
2727
2828
29- def get_language (choice ):
30- return choice ( list (supported_languages .values ()))
29+ def get_language (data ):
30+ return data . draw ( sampled_from ( list (supported_languages .values () )))
3131
3232
3333@given (lists (text ()), text ())
@@ -49,9 +49,9 @@ def test_destination(filepath, preserve_paths, outdir):
4949 assert dest .endswith (".html" )
5050
5151
52- @given (choices (), text ())
53- def test_parse (choice , source ):
54- lang = get_language (choice )
52+ @given (data (), text ())
53+ def test_parse (data , source ):
54+ lang = get_language (data )
5555 parsed = p .parse (source , lang )
5656 for s in parsed :
5757 assert {"code_text" , "docs_text" } == set (s .keys ())
@@ -163,9 +163,9 @@ def test_generate_documentation():
163163 p .generate_documentation (PYCCO_SOURCE , outdir = tempfile .gettempdir ())
164164
165165
166- @given (booleans (), booleans (), choices ())
167- def test_process (preserve_paths , index , choice ):
168- lang_name = choice ( [l ["name" ] for l in supported_languages .values ()])
166+ @given (booleans (), booleans (), data ())
167+ def test_process (preserve_paths , index , data ):
168+ lang_name = data . draw ( sampled_from ( [l ["name" ] for l in supported_languages .values ()]) )
169169 p .process ([PYCCO_SOURCE ], preserve_paths = preserve_paths ,
170170 index = index ,
171171 outdir = tempfile .gettempdir (),
0 commit comments