Skip to content

test_csv_dataset_quotechar test is not covered for Windows envirment #827

Open
@zhangguanheng66

Description

@zhangguanheng66

Here is the test

@unittest.skipIf(sys.platform == "win32", "FIXME: tempfile could not be opened twice on Windows")
def test_csv_dataset_quotechar(self):
# Based on issue #349
example_data = [("text", "label"),
('" hello world', "0"),
('goodbye " world', "1"),
('this is a pen " ', "0")]
with tempfile.NamedTemporaryFile(dir=self.test_dir) as f:
for example in example_data:
f.write("{}\n".format(",".join(example)).encode("latin-1"))
TEXT = data.Field(lower=True, tokenize=lambda x: x.split())
fields = {
"label": ("label", data.Field(use_vocab=False,
sequential=False)),
"text": ("text", TEXT)
}
f.seek(0)
dataset = data.TabularDataset(
path=f.name, format="csv",
skip_header=False, fields=fields,
csv_reader_params={"quotechar": None})
TEXT.build_vocab(dataset)
self.assertEqual(len(dataset), len(example_data) - 1)
for i, example in enumerate(dataset):
self.assertEqual(example.text,
example_data[i + 1][0].lower().split())
self.assertEqual(example.label, example_data[i + 1][1])

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions