Debian Codegraph @

hypothesis-python/tests/nocover/test_dynamic_variable.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.utils.dynamicvariables import DynamicVariable
12
13
14 def test_can_assign():
15 d = DynamicVariable(1)
16 assert d.value == 1
17 with d.with_value(2):
18 assert d.value == 2
19 assert d.value == 1
20
21
22 def test_can_nest():
23 d = DynamicVariable(1)
24 with d.with_value(2):
25 assert d.value == 2
26 with d.with_value(3):
27 assert d.value == 3
28 assert d.value == 2
29 assert d.value == 1