<commit_before>from awsshell import db
import pytest


@pytest.fixture
def shell_db(tmpdir):
    filename = tmpdir.join('docs.db').strpath
    d = db.ConcurrentDBM.create(filename)
    return d


def test_can_get_and_set_value(shell_db):
    shell_db['foo'] = 'bar'
    assert shell_db['foo'] == 'bar'


def test_raise_key_error_when_no_key_exists(shell_db):
    try:
        shell_db['foo']
    except KeyError as e:
        assert 'foo' in str(e)
    else:
        raise AssertionError("Expected KeyError")


def test_can_set_multiple_values(shell_db):
    shell_db['foo'] = 'a'
    shell_db['bar'] = 'b'
    assert shell_db['foo'] == 'a'
    assert shell_db['bar'] == 'b'


def test_can_change_existing_value(shell_db):
    shell_db['foo'] = 'first'<commit_msg>Use pytest.raises<commit_after>from awsshell import db
import pytest


@pytest.fixture
def shell_db(tmpdir):
    filename = tmpdir.join('docs.db').strpath
    d = db.ConcurrentDBM.create(filename)
    return d


def test_can_get_and_set_value(shell_db):
    shell_db['foo'] = 'bar'
    assert shell_db['foo'] == 'bar'


def test_raise_key_error_when_no_key_exists(shell_db):
    with pytest.raises(KeyError) as e:
        shell_db['foo']
    assert 'foo' in str(e.value)


def test_can_set_multiple_values(shell_db):
    shell_db['foo'] = 'a'
    shell_db['bar'] = 'b'
    assert shell_db['foo'] == 'a'
    assert shell_db['bar'] == 'b'


def test_can_change_existing_value(shell_db):
    shell_db['foo'] = 'first'
{'fraction_non_alphanumeric': 0.13464140730717186, 'fraction_numerical': 0.0, 'mean_word_length': 4.135416666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7221783', 'n_tokens_mistral': 562, 'n_tokens_neox': 557, 'n_words': 103}