Python pytest 模块,deprecated_call() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用pytest.deprecated_call()

项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_invalid_enter_exit(self):
        # wrap this test in WarningsRecorder to ensure warning state gets reset
        with WarningsRecorder():
            with pytest.raises(RuntimeError):
                rec = WarningsRecorder()
                rec.__exit__(None, None, None)  # can't exit before entering

            with pytest.raises(RuntimeError):
                rec = WarningsRecorder()
                with rec:
                    with rec:
                        pass  # can't enter twice

#
# ============ test pytest.deprecated_call() ==============
#
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
def test_load_client_ca_unicode(self, context, ca_file):
        """
        Passing the path as unicode raises a warning but works.
        """
        pytest.deprecated_call(
            context.load_client_ca, ca_file.decode("ascii")
        )
项目:2FAssassin    作者:maxwellkoh    | 项目源码 | 文件源码
def test_set_session_id_unicode(self, context):
        """
        `Context.set_session_id` raises a warning if a unicode string is
        passed.
        """
        pytest.deprecated_call(context.set_session_id, u"abc")
项目:tossi    作者:what-studio    | 项目源码 | 文件源码
def test_deprecations():
    pytest.deprecated_call(registry.postfix_particle, u'???', u'????')
    pytest.deprecated_call(tossi.postfix_particle, u'???', u'????')
    pytest.deprecated_call(tossi.get_particle, u'????')
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_ensuretemp(recwarn):
    #pytest.deprecated_call(pytest.ensuretemp, 'hello')
    d1 = pytest.ensuretemp('hello')
    d2 = pytest.ensuretemp('hello')
    assert d1 == d2
    assert d1.check(dir=1)
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_deprecated_call_raises(self):
        excinfo = pytest.raises(AssertionError,
                                "pytest.deprecated_call(dep, 3)")
        assert str(excinfo).find("did not produce") != -1
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_deprecated_call(self):
        pytest.deprecated_call(dep, 0)
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_deprecated_call_ret(self):
        ret = pytest.deprecated_call(dep, 0)
        assert ret == 42
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_deprecated_explicit_call(self):
        pytest.deprecated_call(dep_explicit, 0)
        pytest.deprecated_call(dep_explicit, 0)
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_deprecated_call_pending(self):
        f = lambda: py.std.warnings.warn(PendingDeprecationWarning("hi"))
        pytest.deprecated_call(f)
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_deprecated_call_specificity(self):
        other_warnings = [Warning, UserWarning, SyntaxWarning, RuntimeWarning,
                          FutureWarning, ImportWarning, UnicodeWarning]
        for warning in other_warnings:
            f = lambda: py.std.warnings.warn(warning("hi"))
            with pytest.raises(AssertionError):
                pytest.deprecated_call(f)
项目:py    作者:pytest-dev    | 项目源码 | 文件源码
def test_forwarding_to_warnings_module():
    pytest.deprecated_call(py.log._apiwarn, "1.3", "..")
项目:scikit-optimize    作者:scikit-optimize    | 项目源码 | 文件源码
def test_n_random_starts_Optimizer():
    # n_random_starts got renamed in v0.4
    et = ExtraTreesRegressor(random_state=2)
    with pytest.deprecated_call():
        Optimizer([(0, 1.)], et, n_random_starts=10, acq_optimizer='sampling')