fsdict / tests /

Full commit
# −*− coding: UTF−8 −*−
from __future__ import with_statement
from nose import with_setup
from import nottest, assert_equal, assert_true, assert_false
from fsdict import FSDict

def test_fsdict_pickles():
    """I pass these in to multiprocessing, so I need them to
    serialize properly
    import cPickle
    d1 = FSDict({'a':'b'})
    d2 = cPickle.loads(cPickle.dumps(d1))
    yield assert_equal, d1, d2
    yield assert_equal, d1.work_dir, d2.work_dir

def test_fsdict_loads():
    import pickle
    d = FSDict({'a':'b'})
    yield assert_true, (d.work_dir).exists()
    yield assert_true, (d.work_dir/'a').exists()
    yield assert_equal, d['a'], 'b'
    yield assert_true, 'a' in d
    yield assert_false, 'q' in d
    for key in d:
        yield assert_equal, key, 'a'
    for key, val in d.iteritems():
        yield assert_equal, key, 'a'
        yield assert_equal, val, 'b'
    for val in d.itervalues():
        yield assert_equal, val, 'b'
    yield assert_equal, d.values(), ['b']
    yield assert_equal, d['a'], 'b'
    pickle.dump('c', open(d.work_dir/'a', 'w'))
    yield assert_equal, d['a'], 'c'
    yield assert_false, (d.work_dir/'a').exists()
    yield assert_false, (d.work_dir).exists()
    yield assert_true, e.work_dir.exists()
    yield assert_true, f.work_dir.exists()
    yield assert_false, e.work_dir.exists()
    yield assert_false, f.work_dir.exists()

def test_fsdict_equals():
    as far as equality goes, we want these things to equate as normal dicts
    fsd = FSDict({'a':'b'})
    d1 = {'a':'b'}
    d2 = {'c':'b'}
    d3 = {'a':'c'}
    assert d1 == fsd
    assert d2 != fsd
    assert d3 != fsd
    assert "foo" != fsd