예제 #1
0
def test_hist_then_find_max():
    # Integration test but with typing it's not really needed
    # way back before we have typing this is useful
    # make sure output of one fits into input of another
    d = ['a', 'a', 'b']
    hist = hbh.find_hist(d)
    hbh.max_key_value(hist)  # just make sure it doesn't crash
예제 #2
0
def do_it(fname: str) -> MinMaxKeyCounter:
    with open(fname) as f:
        hist = hbh.find_hist(f)
        min_kv = hbh.min_key_value(hist)
        max_kv = hbh.max_key_value(hist)

    return MinMaxKeyCounter(min_key=min_kv.key,
                            max_key=max_kv.key,
                            max_counter=max_kv.value,
                            min_counter=min_kv.value)
예제 #3
0
def test_find_hist_simple():
    d = ['a', 'a', 'b']
    got = hbh.find_hist(d)
    exp = {'a': 2, 'b': 1}
    assert got == exp  # yes you can compare dict like this
예제 #4
0
def test_find_hist_should_give_empty_dict_for_empty_iterable():
    d = []
    got = hbh.find_hist(d)
    assert got == {}
예제 #5
0
def test_find_hist_should_strip():
    d = ['a\n', 'a', 'b']
    got = hbh.find_hist(d)
    exp = {'a': 2, 'b': 1}
    assert got == exp  # yes you can compare dict like this