コード例 #1
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
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)
コード例 #2
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
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
コード例 #3
0
 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)
コード例 #4
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
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')
コード例 #5
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
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'
コード例 #6
0
    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'
コード例 #7
0
    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
コード例 #8
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
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)
コード例 #9
0
ファイル: test_station.py プロジェクト: ranjitkash/Qcodes
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')
コード例 #10
0
ファイル: test_station.py プロジェクト: simonzihlmann/Qcodes
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')
コード例 #11
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
def test_init_raises():
    with assert_deprecated('The class <C> is deprecated, because '
                           'this is a test.'):
        C('pristine')
コード例 #12
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
def test_assert_deprecated_does_not_raise_wrong_type():
    with pytest.raises(AssertionError):
        with assert_deprecated('entirely different message'):
            warnings.warn('warning')
コード例 #13
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
def test_assert_deprecated_does_not_raise_wrong_msg():
    with pytest.raises(AssertionError):
        with assert_deprecated('entirely different message'):
            issue_deprecation_warning('warning')
コード例 #14
0
ファイル: test_deprecate.py プロジェクト: spauka/Qcodes
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