| 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 |
from hypothesis.internal.reflection import get_pretty_function_description, proxies |
| 13 |
|
| 14 |
|
| 15 |
def test_can_copy_signature_of_unicode_args(): |
| 16 |
def foo(μ): |
| 17 |
return μ |
| 18 |
|
| 19 |
@proxies(foo) |
| 20 |
def bar(μ): |
| 21 |
return foo(μ) |
| 22 |
|
| 23 |
assert bar(1) == 1 |
| 24 |
|
| 25 |
|
| 26 |
def test_can_copy_signature_of_unicode_name(): |
| 27 |
def ā(): |
| 28 |
return 1 |
| 29 |
|
| 30 |
@proxies(ā) |
| 31 |
def bar(): |
| 32 |
return 2 |
| 33 |
|
| 34 |
assert bar() == 2 |
| 35 |
|
| 36 |
|
| 37 |
is_approx_π = lambda x: x == 3.1415 |
| 38 |
|
| 39 |
|
| 40 |
def test_can_handle_unicode_identifier_in_same_line_as_lambda_def(): |
| 41 |
assert get_pretty_function_description(is_approx_π) == "lambda x: x == 3.1415" |
| 42 |
|
| 43 |
|
| 44 |
def test_regression_issue_1700(): |
| 45 |
π = 3.1415 |
| 46 |
|
| 47 |
@given(st.floats(min_value=-π, max_value=π).filter(lambda x: abs(x) > 1e-5)) |
| 48 |
def test_nonzero(x): |
| 49 |
assert x != 0 |
| 50 |
|
| 51 |
test_nonzero() |