diff options
| author | armenqa <[email protected]> | 2024-01-19 12:23:50 +0300 |
|---|---|---|
| committer | armenqa <[email protected]> | 2024-01-19 13:10:03 +0300 |
| commit | 2de0149d0151c514b22bca0760b95b26c9b0b578 (patch) | |
| tree | 2bfed9f3bce7e643ddf048bb61ce3dc0a714bcc2 /contrib/python/traitlets/py3/tests | |
| parent | a8c06d218f12b2406fbce24d194885c5d7b68503 (diff) | |
feat contrib: aiogram 3
Relates: https://st.yandex-team.ru/, https://st.yandex-team.ru/
Diffstat (limited to 'contrib/python/traitlets/py3/tests')
11 files changed, 36 insertions, 23 deletions
diff --git a/contrib/python/traitlets/py3/tests/_warnings.py b/contrib/python/traitlets/py3/tests/_warnings.py index 1fb6e9a9a57..3447fbef8a6 100644 --- a/contrib/python/traitlets/py3/tests/_warnings.py +++ b/contrib/python/traitlets/py3/tests/_warnings.py @@ -1,5 +1,6 @@ # From scikit-image: https://github.com/scikit-image/scikit-image/blob/c2f8c4ab123ebe5f7b827bc495625a32bb225c10/skimage/_shared/_warnings.py # Licensed under modified BSD license +from __future__ import annotations __all__ = ["all_warnings", "expected_warnings"] diff --git a/contrib/python/traitlets/py3/tests/config/test_application.py b/contrib/python/traitlets/py3/tests/config/test_application.py index 61ad751c6ba..73d31432a4e 100644 --- a/contrib/python/traitlets/py3/tests/config/test_application.py +++ b/contrib/python/traitlets/py3/tests/config/test_application.py @@ -4,6 +4,7 @@ Tests for traitlets.config.application.Application # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. +from __future__ import annotations import contextlib import io @@ -17,7 +18,6 @@ from tempfile import TemporaryDirectory from unittest import TestCase, mock import pytest -from pytest import mark from traitlets import Bool, Bytes, Dict, HasTraits, Integer, List, Set, Tuple, Unicode from traitlets.config.application import Application @@ -551,7 +551,7 @@ class TestApplication(TestCase): app.init_bar() self.assertEqual(app.bar.b, 1) - @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") + @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") def test_log_collisions(self): app = MyApp() app.log = logging.getLogger() @@ -572,7 +572,7 @@ class TestApplication(TestCase): assert pjoin(td, name + ".py") in output assert pjoin(td, name + ".json") in output - @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") + @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") def test_log_bad_config(self): app = MyApp() app.log = logging.getLogger() @@ -670,7 +670,7 @@ class TestApplication(TestCase): self.assertEqual(app.running, False) def test_cli_multi_scalar(caplog): class App(Application): aliases = {"opt": "App.opt"} @@ -855,7 +855,7 @@ def test_get_default_logging_config_pythonw(monkeypatch): assert "loggers" in config def caplogconfig(monkeypatch): """Capture logging config events for DictConfigurator objects. diff --git a/contrib/python/traitlets/py3/tests/config/test_argcomplete.py b/contrib/python/traitlets/py3/tests/config/test_argcomplete.py index 0cd992c6125..3f1ce482e88 100644 --- a/contrib/python/traitlets/py3/tests/config/test_argcomplete.py +++ b/contrib/python/traitlets/py3/tests/config/test_argcomplete.py @@ -4,6 +4,7 @@ Tests for argcomplete handling by traitlets.config.application.Application # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. +from __future__ import annotations import io import os @@ -71,7 +72,7 @@ class TestArgcomplete: IFS = "\013" COMP_WORDBREAKS = " \t\n\"'><=;|&(:" - @pytest.fixture + @pytest.fixture() def argcomplete_on(self, mocker): """Mostly borrowed from argcomplete's unit test fixtures @@ -119,7 +120,7 @@ class TestArgcomplete: os.environ["COMP_LINE"] = command os.environ["COMP_POINT"] = str(point) - with pytest.raises(CustomError) as cm: + with pytest.raises(CustomError) as cm: # noqa: PT012 app.argcomplete_kwargs = dict( output_stream=strio, exit_method=CustomError.exit, **kwargs ) @@ -216,4 +217,5 @@ class TestArgcomplete: app = MainApp() completions = set(self.run_completer(app, "app --")) assert completions > {"--Application.", "--MainApp."} - assert "--SubApp1." not in completions and "--SubApp2." not in completions + assert "--SubApp1." not in completions + assert "--SubApp2." not in completions diff --git a/contrib/python/traitlets/py3/tests/config/test_configurable.py b/contrib/python/traitlets/py3/tests/config/test_configurable.py index f6499ea29d1..f1e8ed74a38 100644 --- a/contrib/python/traitlets/py3/tests/config/test_configurable.py +++ b/contrib/python/traitlets/py3/tests/config/test_configurable.py @@ -2,11 +2,12 @@ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. +from __future__ import annotations import logging from unittest import TestCase -from pytest import mark +import pytest from .._warnings import expected_warnings from traitlets.config.application import Application @@ -672,7 +673,7 @@ class TestLogger(TestCase): bar = Integer(config=True) baz = Integer(config=True) - @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") + @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") def test_warn_match(self): logger = logging.getLogger("test_warn_match") cfg = Config({"A": {"bat": 5}}) diff --git a/contrib/python/traitlets/py3/tests/config/test_loader.py b/contrib/python/traitlets/py3/tests/config/test_loader.py index 9d864317bcd..6e1510c2cd1 100644 --- a/contrib/python/traitlets/py3/tests/config/test_loader.py +++ b/contrib/python/traitlets/py3/tests/config/test_loader.py @@ -2,6 +2,7 @@ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. +from __future__ import annotations import copy import os @@ -123,9 +124,8 @@ class TestFileCL(TestCase): with JSONFileConfigLoader(fname, log=log) as config: config.A.b = 1 - with self.assertRaises(TypeError): - with JSONFileConfigLoader(fname, log=log) as config: - config.A.cant_json = lambda x: x + with self.assertRaises(TypeError), JSONFileConfigLoader(fname, log=log) as config: + config.A.cant_json = lambda x: x loader = JSONFileConfigLoader(fname, log=log) cfg = loader.load_config() diff --git a/contrib/python/traitlets/py3/tests/test_traitlets.py b/contrib/python/traitlets/py3/tests/test_traitlets.py index 07c95ca2519..dfcf3f0f4b5 100644 --- a/contrib/python/traitlets/py3/tests/test_traitlets.py +++ b/contrib/python/traitlets/py3/tests/test_traitlets.py @@ -5,6 +5,7 @@ # # Adapted from enthought.traits, Copyright (c) Enthought, Inc., # also under the terms of the Modified BSD License. +from __future__ import annotations import pickle import re @@ -1254,7 +1255,7 @@ class TraitTestBase(TestCase): try: self.assertRaises(TraitError, self.assign, value) except AssertionError: - assert False, value + assert False, value # noqa: PT015 def test_default_value(self): if hasattr(self, "_default_value"): @@ -1784,7 +1785,7 @@ class TestMultiTuple(TraitTestBase): @pytest.mark.parametrize( "Trait", - ( + ( # noqa: PT007 List, Tuple, Set, @@ -1808,7 +1809,7 @@ def test_allow_none_default_value(Trait): @pytest.mark.parametrize( "Trait, default_value", - ((List, []), (Tuple, ()), (Set, set()), (Dict, {}), (Integer, 0), (Unicode, "")), + ((List, []), (Tuple, ()), (Set, set()), (Dict, {}), (Integer, 0), (Unicode, "")), # noqa: PT007 ) def test_default_value(Trait, default_value): class C(HasTraits): @@ -1822,7 +1823,7 @@ def test_default_value(Trait, default_value): @pytest.mark.parametrize( "Trait, default_value", - ((List, []), (Tuple, ()), (Set, set())), + ((List, []), (Tuple, ()), (Set, set())), # noqa: PT007 ) def test_subclass_default_value(Trait, default_value): """Test deprecated default_value=None behavior for Container subclass traits""" @@ -2150,7 +2151,7 @@ class TestLink(TestCase): self.i = change.new * 2 mc = MyClass() - l = link((mc, "i"), (mc, "j")) # noqa + l = link((mc, "i"), (mc, "j")) # noqa: E741 self.assertRaises(TraitError, setattr, mc, "i", 2) def test_link_broken_at_target(self): @@ -2163,7 +2164,7 @@ class TestLink(TestCase): self.j = change.new * 2 mc = MyClass() - l = link((mc, "i"), (mc, "j")) # noqa + l = link((mc, "i"), (mc, "j")) # noqa: E741 self.assertRaises(TraitError, setattr, mc, "j", 2) @@ -2393,7 +2394,7 @@ class OrderTraits(HasTraits): i = Unicode() j = Unicode() k = Unicode() - l = Unicode() # noqa + l = Unicode() # noqa: E741 def _notify(self, name, old, new): """check the value of all traits when each trait change is triggered @@ -2819,7 +2820,7 @@ def test_default_mro(): def test_cls_self_argument(): class X(HasTraits): - def __init__(__self, cls, self): # noqa + def __init__(__self, cls, self): pass x = X(cls=None, self=None) @@ -2889,7 +2890,7 @@ def _from_string_test(traittype, s, expected): else: cast = trait.from_string if type(expected) is type and issubclass(expected, Exception): - with pytest.raises(expected): + with pytest.raises(expected): # noqa: PT012 value = cast(s) trait.validate(CrossValidationStub(), value) # type:ignore else: diff --git a/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py b/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py index 700199108f1..685ea71f695 100644 --- a/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py +++ b/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py @@ -3,6 +3,8 @@ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. # +from __future__ import annotations + from traitlets import Dict, Instance, Integer, Unicode, Union from traitlets.config import Configurable diff --git a/contrib/python/traitlets/py3/tests/test_traitlets_enum.py b/contrib/python/traitlets/py3/tests/test_traitlets_enum.py index c39007e8a05..ac19e9d519f 100644 --- a/contrib/python/traitlets/py3/tests/test_traitlets_enum.py +++ b/contrib/python/traitlets/py3/tests/test_traitlets_enum.py @@ -2,6 +2,7 @@ """ Test the trait-type ``UseEnum``. """ +from __future__ import annotations import enum import unittest @@ -280,7 +281,7 @@ class TestFuzzyEnum(unittest.TestCase): example = FuzzyExample() for color in color_choices: - for wlen in range(0, 2): + for wlen in range(2): value = color[wlen:] example.color = value diff --git a/contrib/python/traitlets/py3/tests/utils/test_bunch.py b/contrib/python/traitlets/py3/tests/utils/test_bunch.py index 223124d7d5e..90efe982739 100644 --- a/contrib/python/traitlets/py3/tests/utils/test_bunch.py +++ b/contrib/python/traitlets/py3/tests/utils/test_bunch.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from traitlets.utils.bunch import Bunch diff --git a/contrib/python/traitlets/py3/tests/utils/test_decorators.py b/contrib/python/traitlets/py3/tests/utils/test_decorators.py index d6bf8414e5a..39b882c0ea8 100644 --- a/contrib/python/traitlets/py3/tests/utils/test_decorators.py +++ b/contrib/python/traitlets/py3/tests/utils/test_decorators.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from inspect import Parameter, signature from unittest import TestCase diff --git a/contrib/python/traitlets/py3/tests/utils/test_importstring.py b/contrib/python/traitlets/py3/tests/utils/test_importstring.py index 8ce28add41e..43fcdaaff2b 100644 --- a/contrib/python/traitlets/py3/tests/utils/test_importstring.py +++ b/contrib/python/traitlets/py3/tests/utils/test_importstring.py @@ -4,6 +4,7 @@ # Adapted from enthought.traits, Copyright (c) Enthought, Inc., # also under the terms of the Modified BSD License. """Tests for traitlets.utils.importstring.""" +from __future__ import annotations import os from unittest import TestCase |
