Example #1
0
def test_sample_different_line_counts():
    with sample(resource(iris_url), lines=10) as fn:
        with open(fn, 'r') as f:
            assert len(list(f)) == 10

    with sample(resource(iris_url), lines=5) as fn:
        with open(fn, 'r') as f:
            assert len(list(f)) == 5
Example #2
0
def test_sample_different_encoding():
    encoding = 'latin-1'
    lines = 10
    with sample(resource(iris_url), lines=lines, encoding=encoding) as fn:
        with codecs.open(fn, 'r', encoding=encoding) as f:
            assert len(list(f)) == lines