11
11
import pycco .generate_index as generate_index
12
12
import pycco .main as p
13
13
from 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
15
15
from pycco .languages import supported_languages
16
16
17
17
try :
26
26
FOO_FUNCTION = """def foo():\n return True"""
27
27
28
28
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 () )))
31
31
32
32
33
33
@given (lists (text ()), text ())
@@ -49,9 +49,9 @@ def test_destination(filepath, preserve_paths, outdir):
49
49
assert dest .endswith (".html" )
50
50
51
51
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 )
55
55
parsed = p .parse (source , lang )
56
56
for s in parsed :
57
57
assert {"code_text" , "docs_text" } == set (s .keys ())
@@ -163,9 +163,9 @@ def test_generate_documentation():
163
163
p .generate_documentation (PYCCO_SOURCE , outdir = tempfile .gettempdir ())
164
164
165
165
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 ()]) )
169
169
p .process ([PYCCO_SOURCE ], preserve_paths = preserve_paths ,
170
170
index = index ,
171
171
outdir = tempfile .gettempdir (),
0 commit comments