<commit_before>from hash_table import HashTable
import io
import pytest


words = []

with io.open('/usr/share/dict/words', 'r') as word_file:
    words = word_file.readlines()


def test_init():
    ht = HashTable()
    assert len(ht.table) == 1024
    ht2 = HashTable(10000)
    assert len(ht2.table) == 10000


def test_hash():
    ht = HashTable()
    ht.set('coffee', 'coffee')
    assert ht.get('coffee') == 'coffee'


def test_duplicate_hash_val():
    ht = HashTable()
    ht.set('bob', 'bob')
    ht.set('obb', 'obb')
    assert ht.get('bob') == 'bob'
    assert ht.get('obb') == 'obb'


def test_word_file():
    ht = HashTable()
    for word in words:
        ht.set(word, word)
    assert ht.get(words[654]) == words[654]
    assert ht.get(words[3541]) == words[3541]
    assert ht.get(words[6541]) == words[6541]


def test_non_item():
    ht = HashTable()
    ht.set('coffee', 'coffee')
    with pytest.raises(KeyError):
        ht.get('milk')


def test_non_bucket():
    ht = HashTable()
    with pytest.raises(IndexError):
        ht.table[1025]


def test_non_string():
    ht = HashTable()
    with pytest.raises(TypeError):
        ht.set(13, 13)<commit_msg>Add test to ensure memory separation when using multiple hash tables<commit_after>from hash_table import HashTable
import io
import pytest


words = []

with io.open('/usr/share/dict/words', 'r') as word_file:
    words = word_file.readlines()


def test_init():
    ht = HashTable()
    assert len(ht.table) == 1024
    ht2 = HashTable(10000)
    assert len(ht2.table) == 10000


def test_hash():
    ht = HashTable()
    ht.set('coffee', 'coffee')
    assert ht.get('coffee') == 'coffee'


def test_duplicate_hash_val():
    ht = HashTable()
    ht.set('bob', 'bob')
    ht.set('obb', 'obb')
    assert ht.get('bob') == 'bob'
    assert ht.get('obb') == 'obb'


def test_word_file():
    ht = HashTable()
    for word in words:
        ht.set(word, word)
    assert ht.get(words[654]) == words[654]
    assert ht.get(words[3541]) == words[3541]
    assert ht.get(words[6541]) == words[6541]


def test_non_item():
    ht = HashTable()
    ht.set('coffee', 'coffee')
    with pytest.raises(KeyError):
        ht.get('milk')


def test_non_bucket():
    ht = HashTable()
    with pytest.raises(IndexError):
        ht.table[1025]


def test_non_string():
    ht = HashTable()
    with pytest.raises(TypeError):
        ht.set(13, 13)


def test_multiple_tables():
    ht1 = HashTable()
    ht2 = HashTable()
    ht1.set('coffee', 'coffee')
    ht1.set('eggs', 'eggs')
    ht2.set('bacon', 'bacon')
    with pytest.raises(KeyError):
        ht1.get('bacon')
    with pytest.raises(KeyError):
        ht2.get('coffee')
{'fraction_non_alphanumeric': 0.16221232368225685, 'fraction_numerical': 0.036748329621380846, 'mean_word_length': 3.1082317073170733, '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': '6761349', 'n_tokens_mistral': 1127, 'n_tokens_neox': 996, 'n_words': 215}