Debian Codegraph @

hypothesis-python/tests/nocover/test_eval_as_source.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.internal.reflection import source_exec_as_module
12
13
14 def test_can_eval_as_source():
15 assert source_exec_as_module("foo=1").foo == 1
16
17
18 def test_caches():
19 x = source_exec_as_module("foo=2")
20 y = source_exec_as_module("foo=2")
21 assert x is y
22
23
24 RECURSIVE = """
25 from hypothesis.internal.reflection import source_exec_as_module
26
27 def test_recurse():
28 assert not (
29 source_exec_as_module("too_much_recursion = False").too_much_recursion)
30 """
31
32
33 def test_can_call_self_recursively():
34 source_exec_as_module(RECURSIVE).test_recurse()