def test_write_cache_file():
    from rosdep2.sources_list import write_cache_file, compute_filename_hash
    tempdir = tempfile.mkdtemp()

    filepath = write_cache_file(tempdir, 'foo', {'data': 1})
    computed_path = os.path.join(tempdir, compute_filename_hash('foo'))
    assert os.path.samefile(filepath, computed_path)
    with open(filepath, 'r') as f:
        assert {'data': 1} == yaml.load(f.read())
def test_write_cache_file():
    from rosdep2.sources_list import write_cache_file, compute_filename_hash
    tempdir = tempfile.mkdtemp()
    
    filepath = write_cache_file(tempdir, 'foo', {'data': 1})
    computed_path = os.path.join(tempdir, compute_filename_hash('foo'))
    assert os.path.samefile(filepath, computed_path)
    with open(filepath, 'r') as f:
        assert {'data': 1} == yaml.load(f.read())
def test_write_cache_file():
    from rosdep2.sources_list import write_cache_file, compute_filename_hash, PICKLE_CACHE_EXT
    import cPickle
    tempdir = tempfile.mkdtemp()
    
    filepath = write_cache_file(tempdir, 'foo', {'data': 1})  + PICKLE_CACHE_EXT
    computed_path = os.path.join(tempdir, compute_filename_hash('foo')) + PICKLE_CACHE_EXT
    assert os.path.samefile(filepath, computed_path)
    with open(filepath, 'r') as f:
        assert {'data': 1} == cPickle.loads(f.read())
Example #4
0
def test_write_cache_file():
    from rosdep2.sources_list import write_cache_file, compute_filename_hash, PICKLE_CACHE_EXT
    try:
        import cPickle as pickle
    except ImportError:
        import pickle
    tempdir = tempfile.mkdtemp()

    filepath = write_cache_file(tempdir, 'foo', {'data': 1}) + PICKLE_CACHE_EXT
    computed_path = os.path.join(tempdir, compute_filename_hash('foo')) + PICKLE_CACHE_EXT
    assert os.path.samefile(filepath, computed_path)
    with open(filepath, 'rb') as f:
        assert {'data': 1} == pickle.loads(f.read())