<commit_before>#!/usr/bin/python3
import keyvaluestore

c = keyvaluestore.Container("/tmp/test-keyvaluestore")
assert c.getkeys() == []
c.set(1, 2)
assert c.get(1) == ("any picklable object", 2)
assert c.get("nonexisting") == None
assert c.getkeys() == [1]
c.revert()
assert c.getkeys() == []<commit_msg>KeyValue store: testing still unusable<commit_after>#!/usr/bin/python3
import keyvaluestore


def throws(code, errortype):
    try:
        code()
    except errortype, e:
        return True
    else:
        return False

assert throws(lambda: 1, AssertionError)
assert throws(lambda: open('???'), OSError)


filename = '/tmp/test-keyvaluestore'

with keyvaluestore.Container(filename) as c:
    assert c.getkeys() == []
    c.set(1, 2)
    assert c.get(1) == ('any picklable object', 2)
    assert c.get('nonexisting') == None
    assert c.getkeys() == [1]
    c.revert()
    assert c.getkeys() == []

{'fraction_non_alphanumeric': 0.16629955947136563, 'fraction_numerical': 0.014317180616740088, 'mean_word_length': 3.734375, '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': '900407', 'n_tokens_mistral': 335, 'n_tokens_neox': 324, 'n_words': 77}