Example #1
0
def test_find_datafile(codec, dataset):
    obj = codec.cls()

    print(dataset.filename)
    print(data_dir)
    files = munge.find_datafile('set0', data_dir)
    # should == number of codec tests
    assert files

    assert not munge.find_datafile('nonexistant', [])

    # test codec override
    files = munge.find_datafile(dataset.filename, this_dir, {('json',): munge.get_codecs()[('json',)]})
    assert 1 == len(files)
    load = files[0]
    assert os.path.join(this_dir, dataset.filename + '.json') == load[1]
    assert hasattr(load[0], 'load')
    assert dataset.expected == load[0]().load(open(load[1]))
Example #2
0
def test_codec_registry():
    assert munge.get_codecs()
Example #3
0
import filecmp
import imp
import os
import pytest
import sys

#from munge.codec.yaml import Yaml
#import munge.codec
import munge
import munge.codec.all

this_dir = os.path.dirname(__file__)
data_dir = os.path.join(this_dir, 'data')

test_codecs=[]
for tags, cls in munge.get_codecs().items():
    if any(name in ('json', 'yaml') for name in tags):
        test_codecs.append(cls)

class DataSet0(object):
    name='set0'
    filename='data/' + name

    expected = {'munge': {'str0': 'str0', 'list0': ['item0', 'item1'], 'int0': 42}}

data = (
    DataSet0,
    )

class DataTab0(object):
    name='tab0'
Example #4
0
import filecmp
import imp
import os
import pytest
import sys

#from munge.codec.yaml import Yaml
#import munge.codec
import munge
import munge.codec.all

this_dir = os.path.dirname(__file__)
data_dir = os.path.join(this_dir, 'data')

test_codecs=[]
for tags, cls in list(munge.get_codecs().items()):
    if any(name in ('json', 'yaml') for name in tags):
        test_codecs.append(cls)

class DataSet0(object):
    name='set0'
    filename='data/' + name

    expected = {'munge': {'str0': 'str0', 'list0': ['item0', 'item1'], 'int0': 42}}

data = (
    DataSet0,
    )

class DataTab0(object):
    name='tab0'
Example #5
0
import filecmp
import imp
import os
import pytest
import sys

import facsimile
import facsimile.codec
import munge
import munge.codec.all

from util import mk_proj
from proj0 import Proj0

has_codecs = [exts[0] for exts in munge.get_codecs().keys()]

def obj(release_environment, **kwargs):
    return mk_proj(Proj0, release_environment, **kwargs)

def test_codec_init():
    codecs = facsimile.codec.get_codecs()
    assert len(codecs)
    assert len(has_codecs) == len(codecs)

def TODO_test_add_codec():
    with pytest.raises(ValueError):
        facsimile.codec.add_codec(['json'], None)

def test_get_codec():
    for each in has_codecs: