Ejemplo n.º 1
0
def test_table_error_read_closed():
    table = Table("data/table.csv")
    with pytest.raises(FrictionlessException) as excinfo:
        table.read_data()
    error = excinfo.value.error
    assert error.code == "error"
    assert error.note == 'the table has not been opened by "table.open()"'
Ejemplo n.º 2
0
def test_table_reset_on_close_issue_190():
    query = Query(limit_rows=1)
    source = [["1", "english"], ["2", "中国人"]]
    table = Table(source, headers=False, query=query)
    table.open()
    table.read_data() == [["1", "english"]]
    table.open()
    table.read_data() == [["1", "english"]]
    table.close()
Ejemplo n.º 3
0
def test_table_compression_local_csv_zip_multiple_open():
    # That's how `tableschema.iter()` acts
    table = Table("data/table.csv.zip")
    table.open()
    assert table.header == ["id", "name"]
    assert table.read_data() == [["1", "english"], ["2", "中国人"]]
    table.close()
    table.open()
    assert table.header == ["id", "name"]
    assert table.read_data() == [["1", "english"], ["2", "中国人"]]
    table.close()