def test_class_method_raises(): with assert_deprecated( 'The function <static_method> is deprecated, because ' 'this is a test.'): C.class_method(1) with pytest.warns(expected_warning=QCoDeSDeprecationWarning): c = C('pristine') with assert_deprecated( 'The function <static_method> is deprecated, because ' 'this is a test.'): c.class_method(1)
def test_static_method_raises(self): with assert_deprecated( 'The function <static_method> is deprecated, because ' 'this is a test.'): assert C.static_method(1) == 2 with pytest.warns(expected_warning=QCoDeSDeprecationWarning): c = C('pristine') with assert_deprecated( 'The function <static_method> is deprecated, because ' 'this is a test.'): assert c.static_method(1) == 2
def test_class_method_raises(self): with assert_deprecated( 'The function <static_method> is deprecated, because ' 'this is a test.'): C.class_method(1) with _ignore_warnings(): c = C('pristine') with assert_deprecated( 'The function <static_method> is deprecated, because ' 'this is a test.'): c.class_method(1)
def test_assert_deprecated_raises(): with assert_deprecated( 'The use of this function is deprecated, because ' 'of this being a test. Use \"a real function\" as an ' 'alternative.'): issue_deprecation_warning('use of this function', 'of this being a test', 'a real function')
def test_setter_raises(self): with pytest.warns(expected_warning=QCoDeSDeprecationWarning): c = C('pristine') with assert_deprecated('The function <method> is deprecated, because ' 'this is a test.'): c.prop = 'changed'
def test_setter_raises(self): with _ignore_warnings(): c = C('pristine') with assert_deprecated('The function <method> is deprecated, because ' 'this is a test.'): c.prop = 'changed'
def test_property_raises(self): with _ignore_warnings(): c = C('pristine') with assert_deprecated('The function <method> is deprecated, because ' 'this is a test.'): _ = c.prop # pylint: disable=pointless-statement
def test_similar_output(): def _add_one(x): return 1 + x @deprecate(reason='this function is for private use only') def add_one(x): return _add_one(x) with assert_deprecated('The function <add_one> is deprecated, because ' 'this function is for private use only.'): assert add_one(1) == _add_one(1)
def test_deprecated_driver_keyword(): st = station_from_config_str(""" instruments: mock: driver: qcodes.tests.instrument_mocks type: DummyChannelInstrument """) with assert_deprecated( deprecation_message( 'use of the "driver"-keyword in the station configuration file', alternative='the "type"-keyword instead, prepending the driver value' ' to it')): st.load_instrument('mock')
def test_deprecated_limits_keyword_as_string(): st = station_from_config_str(""" instruments: mock: type: qcodes.tests.instrument_mocks.DummyInstrument init: gates: {"ch1"} parameters: ch1: limits: -10, 10 """) with assert_deprecated( deprecation_message( 'use of a comma separated string for the limits keyword', alternative='an array like "[lower_lim, upper_lim]"')): st.load_instrument('mock')
def test_init_raises(): with assert_deprecated('The class <C> is deprecated, because ' 'this is a test.'): C('pristine')
def test_assert_deprecated_does_not_raise_wrong_type(): with pytest.raises(AssertionError): with assert_deprecated('entirely different message'): warnings.warn('warning')
def test_assert_deprecated_does_not_raise_wrong_msg(): with pytest.raises(AssertionError): with assert_deprecated('entirely different message'): issue_deprecation_warning('warning')
def test_property_raises(): with pytest.warns(expected_warning=QCoDeSDeprecationWarning): c = C('pristine') with assert_deprecated('The function <method> is deprecated, because ' 'this is a test.'): _ = c.prop # pylint: disable=pointless-statement