예제 #1
0
파일: test_json.py 프로젝트: luizirber/odo
def jsonlines_file(data):
    with tmpfile('.json') as fn:
        with open(fn, 'w') as f:
            for item in data:
                json.dump(item, f, default=json_dumps)
                f.write('\n')

        yield fn
예제 #2
0
파일: test_json.py 프로젝트: MoherX/odo
def jsonlines_file(data):
    with tmpfile('.json') as fn:
        with open(fn, 'w') as f:
            for item in data:
                json.dump(item, f, default=json_dumps)
                f.write('\n')

        yield fn
예제 #3
0
파일: test_json.py 프로젝트: luizirber/odo
def test_multiple_jsonlines():
    a, b = '_test_a1.json', '_test_a2.json'
    try:
        with ignoring(OSError):
            os.remove(a)
        with ignoring(OSError):
            os.remove(b)
        with open(a, 'w') as f:
            json.dump(dat, f)
        with open(b'_test_a2.json', 'w') as f:
            json.dump(dat, f)
        r = resource('_test_a*.json')
        result = convert(list, r)
        assert len(result) == len(dat) * 2
    finally:
        with ignoring(OSError):
            os.remove(a)
        with ignoring(OSError):
            os.remove(b)
예제 #4
0
파일: test_json.py 프로젝트: MoherX/odo
def test_multiple_jsonlines():
    a, b = '_test_a1.json', '_test_a2.json'
    try:
        with ignoring(OSError):
            os.remove(a)
        with ignoring(OSError):
            os.remove(b)
        with open(a, 'w') as f:
            json.dump(dat, f)
        with open(b'_test_a2.json', 'w') as f:
            json.dump(dat, f)
        r = resource('_test_a*.json')
        result = convert(list, r)
        assert len(result) == len(dat) * 2
    finally:
        with ignoring(OSError):
            os.remove(a)
        with ignoring(OSError):
            os.remove(b)
예제 #5
0
파일: test_json.py 프로젝트: luizirber/odo
def json_file(data):
    with tmpfile('.json') as fn:
        with open(fn, 'w') as f:
            json.dump(data, f, default=json_dumps)

        yield fn
예제 #6
0
파일: test_json.py 프로젝트: MoherX/odo
def json_file(data):
    with tmpfile('.json') as fn:
        with open(fn, 'w') as f:
            json.dump(data, f, default=json_dumps)

        yield fn