/
niceSOFT
/
python3-pytest
Обзор
Документация
Войти
/
niceSOFT
/
python3-pytest
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
9.1.0.dev0
testing/test_scope.py
41 строка
1 KB
Ronny Pfannschmidt
RFC: from __future__ import annotations + migrate
20 июн 2024, 12:03
20 июн 2024, 12:03
9295f9f
Код
Авторство
О чём код?
from __future__ import annotations import re from _pytest.scope import Scope import pytest def test_ordering() -> None: assert Scope.Session > Scope.Package assert Scope.Package > Scope.Module assert Scope.Module > Scope.Class assert Scope.Class > Scope.Function def test_next_lower() -> None: assert Scope.Session.next_lower() is Scope.Package assert Scope.Package.next_lower() is Scope.Module assert Scope.Module.next_lower() is Scope.Class assert Scope.Class.next_lower() is Scope.Function with pytest.raises(ValueError, match="Function is the lower-most scope"): Scope.Function.next_lower() def test_next_higher() -> None: assert Scope.Function.next_higher() is Scope.Class assert Scope.Class.next_higher() is Scope.Module assert Scope.Module.next_higher() is Scope.Package assert Scope.Package.next_higher() is Scope.Session with pytest.raises(ValueError, match="Session is the upper-most scope"): Scope.Session.next_higher() def test_from_user() -> None: assert Scope.from_user("module", "for parametrize", "some::id") is Scope.Module expected_msg = "for parametrize from some::id got an unexpected scope value 'foo'" with pytest.raises(pytest.fail.Exception, match=re.escape(expected_msg)): Scope.from_user("foo", "for parametrize", "some::id") # type:ignore[arg-type]