コード例 #1
0
ファイル: test_substitute.py プロジェクト: cessor/kazookid
def test_substitute_dictionaries_but_only_if_configured():
    '''Substitute: dict.get returns nothing if the value was not configured with __setitem__'''

    # Arrange
    key = 'key'
    value = 42

    # System under Test
    substitute = Substitute()

    # Act: Run, No Default
    actual_value = substitute.get('key')

    # Assert
    assert_equal(actual_value, None)

    # Act: Run, With Default
    actual_value = substitute.get('key', 1)

    # Assert
    assert_equal(actual_value, 1)
コード例 #2
0
ファイル: test_substitute.py プロジェクト: cessor/kazookid
def test_substitute_dictionaries_return_configured_dictionary_values():
    '''Substitute: dict.get returns values configured by __setitem__'''

    # Arrange
    key = 'key'
    value = 42

    # System under Test
    substitute = Substitute()

    # Act: Configure
    substitute[key] = value

    # Act: Run
    actual_value = substitute.get('key', None)

    # Assert
    assert_equal(actual_value, 42)
コード例 #3
0
ファイル: test_substitute.py プロジェクト: cessor/kazookid
def test_substitute_dictionaries_can_use_get_normally():
    '''Substitute: How to use dict.get'''

    # Arrange
    key = 'key'
    value = 42

    # System under Test
    substitute = Substitute()

    # Act: Configure
    substitute.get.returns(42)

    # Act: Run
    actual_value = substitute.get('key', None)

    # Assert
    assert_equal(actual_value, 42)