diff options
author | asatarin <asatarin@yandex-team.ru> | 2022-02-10 16:47:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:30 +0300 |
commit | 4ca29390ac54b7877174de542de47532c67453b5 (patch) | |
tree | 14f6fc2edf989ce65a7555e8882e3eae3e9306fe /contrib/python/PyHamcrest/tests | |
parent | 05f59b2581f074c756adaee6b260014ac3a0c3ec (diff) | |
download | ydb-4ca29390ac54b7877174de542de47532c67453b5.tar.gz |
Restoring authorship annotation for <asatarin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/PyHamcrest/tests')
-rw-r--r-- | contrib/python/PyHamcrest/tests/test_raises.py | 90 | ||||
-rw-r--r-- | contrib/python/PyHamcrest/tests/test_string_description.py | 34 | ||||
-rw-r--r-- | contrib/python/PyHamcrest/tests/ya.make | 24 |
3 files changed, 74 insertions, 74 deletions
diff --git a/contrib/python/PyHamcrest/tests/test_raises.py b/contrib/python/PyHamcrest/tests/test_raises.py index 4c9ff4e040e..c1a1d4c9070 100644 --- a/contrib/python/PyHamcrest/tests/test_raises.py +++ b/contrib/python/PyHamcrest/tests/test_raises.py @@ -1,45 +1,45 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -__author__ = 'asatarin@yandex-team.ru' - - -class TestException(RuntimeError): - def __init__(self, *args, **kwargs): - super(TestException, self).__init__(*args, **kwargs) - self.prop = "property" - - -def raises_exception(): - raise TestException() - - -def returns_value(): - return 'my_return_value' - - -def test_raises(): - """ - >>> from hamcrest import assert_that - >>> from hamcrest import has_property - >>> from hamcrest import not_, raises - >>> raises(TestException).matches(raises_exception) - True - >>> raises(TestException, matcher=has_property("prop", "property")).matches(raises_exception) - True - >>> raises(TestException, matcher=has_property("prop", "fail")).matches(raises_exception) - False - >>> raises(TestException, matcher=not_(has_property("prop", "fail"))).matches(raises_exception) - True - >>> raises(TestException, matcher=not_(has_property("prop", "property"))).matches(raises_exception) - False - - >>> assert_that(returns_value, raises(TestException), 'message') - Traceback (most recent call last): - ... - AssertionError: message - Expected: Expected a callable raising <class '__tests__.test_raises.TestException'> - but: No exception raised and actual return value = 'my_return_value' - <BLANKLINE> - """ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +__author__ = 'asatarin@yandex-team.ru' + + +class TestException(RuntimeError): + def __init__(self, *args, **kwargs): + super(TestException, self).__init__(*args, **kwargs) + self.prop = "property" + + +def raises_exception(): + raise TestException() + + +def returns_value(): + return 'my_return_value' + + +def test_raises(): + """ + >>> from hamcrest import assert_that + >>> from hamcrest import has_property + >>> from hamcrest import not_, raises + >>> raises(TestException).matches(raises_exception) + True + >>> raises(TestException, matcher=has_property("prop", "property")).matches(raises_exception) + True + >>> raises(TestException, matcher=has_property("prop", "fail")).matches(raises_exception) + False + >>> raises(TestException, matcher=not_(has_property("prop", "fail"))).matches(raises_exception) + True + >>> raises(TestException, matcher=not_(has_property("prop", "property"))).matches(raises_exception) + False + + >>> assert_that(returns_value, raises(TestException), 'message') + Traceback (most recent call last): + ... + AssertionError: message + Expected: Expected a callable raising <class '__tests__.test_raises.TestException'> + but: No exception raised and actual return value = 'my_return_value' + <BLANKLINE> + """ diff --git a/contrib/python/PyHamcrest/tests/test_string_description.py b/contrib/python/PyHamcrest/tests/test_string_description.py index 40cbdd226eb..012d2a502ff 100644 --- a/contrib/python/PyHamcrest/tests/test_string_description.py +++ b/contrib/python/PyHamcrest/tests/test_string_description.py @@ -1,17 +1,17 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from hamcrest import assert_that, empty, equal_to - -__author__ = 'asatarin@yandex-team.ru' - - -def test_string_description_is_fast(): - list_of_very_long_strings = ["aa"*1000 for _ in range(10000)] - try: - assert_that(list_of_very_long_strings, empty()) - x = 0 - except AssertionError as e: - x = len(str(e)) - - assert_that(x, equal_to(20040048)) +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from hamcrest import assert_that, empty, equal_to + +__author__ = 'asatarin@yandex-team.ru' + + +def test_string_description_is_fast(): + list_of_very_long_strings = ["aa"*1000 for _ in range(10000)] + try: + assert_that(list_of_very_long_strings, empty()) + x = 0 + except AssertionError as e: + x = len(str(e)) + + assert_that(x, equal_to(20040048)) diff --git a/contrib/python/PyHamcrest/tests/ya.make b/contrib/python/PyHamcrest/tests/ya.make index 65193017939..360348e96a7 100644 --- a/contrib/python/PyHamcrest/tests/ya.make +++ b/contrib/python/PyHamcrest/tests/ya.make @@ -1,16 +1,16 @@ OWNER(g:python-contrib) - + PY23_TEST() - + NO_LINT() -TEST_SRCS( - test_raises.py - test_string_description.py -) - -PEERDIR( - contrib/python/PyHamcrest -) - -END() +TEST_SRCS( + test_raises.py + test_string_description.py +) + +PEERDIR( + contrib/python/PyHamcrest +) + +END() |