def test_ndjson_parser(): source = 'data/table.ndjson' encoding = None loader = Mock() loader.load = Mock(return_value=io.open(source, encoding='utf-8')) parser = NDJSONParser() assert parser.closed is True parser.open(source, encoding, loader) assert parser.closed is False assert list(parser.extended_rows) == [ (1, ['id', 'name'], [1, 'english']), (2, ['id', 'name'], [2, '中国人']), ] assert len(list(parser.extended_rows)) == 0 parser.reset() assert len(list(parser.extended_rows)) == 2 parser.close() assert parser.closed