Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 65f774b

Browse files
authored
Fix Mock tests due to change in datasets directory (#1749)
1 parent d963bdb commit 65f774b

23 files changed

+37
-25
lines changed

test/datasets/test_agnews.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TestAGNews(TempDirMixin, TorchtextTestCase):
4242
def setUpClass(cls):
4343
super().setUpClass()
4444
cls.root_dir = cls.get_base_temp_dir()
45-
cls.samples = _get_mock_dataset(cls.root_dir)
45+
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
4646
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
4747
cls.patcher.start()
4848

test/datasets/test_amazonreviews.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def tearDownClass(cls):
6969

7070
@nested_params([AmazonReviewFull, AmazonReviewPolarity], ["train", "test"])
7171
def test_amazon_reviews(self, amazon_review_dataset, split):
72-
expected_samples = _get_mock_dataset(self.root_dir, amazon_review_dataset.__name__)[split]
72+
expected_samples = _get_mock_dataset(os.path.join(self.root_dir, "datasets"), amazon_review_dataset.__name__)[
73+
split
74+
]
7375
dataset = amazon_review_dataset(root=self.root_dir, split=split)
7476
samples = list(dataset)
7577

test/datasets/test_cc100.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TestCC100(TempDirMixin, TorchtextTestCase):
4040
def setUpClass(cls):
4141
super().setUpClass()
4242
cls.root_dir = cls.get_base_temp_dir()
43-
cls.samples = _get_mock_dataset(cls.root_dir)
43+
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
4444
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
4545
cls.patcher.start()
4646

test/datasets/test_cola.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TestCoLA(TempDirMixin, TorchtextTestCase):
5151
def setUpClass(cls):
5252
super().setUpClass()
5353
cls.root_dir = cls.get_base_temp_dir()
54-
cls.samples = _get_mock_dataset(cls.root_dir)
54+
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
5555
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
5656
cls.patcher.start()
5757

test/datasets/test_conll2000chunking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TestCoNLL2000Chunking(TempDirMixin, TorchtextTestCase):
5353
def setUpClass(cls):
5454
super().setUpClass()
5555
cls.root_dir = cls.get_base_temp_dir()
56-
cls.samples = _get_mock_dataset(cls.root_dir)
56+
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
5757
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
5858
cls.patcher.start()
5959

test/datasets/test_dbpedia.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TestDBpedia(TempDirMixin, TorchtextTestCase):
5050
def setUpClass(cls):
5151
super().setUpClass()
5252
cls.root_dir = cls.get_base_temp_dir()
53-
cls.samples = _get_mock_dataset(cls.root_dir)
53+
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
5454
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
5555
cls.patcher.start()
5656

test/datasets/test_enwik9.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TestEnWik9(TempDirMixin, TorchtextTestCase):
4747
def setUpClass(cls):
4848
super().setUpClass()
4949
cls.root_dir = cls.get_base_temp_dir()
50-
cls.samples = _get_mock_dataset(cls.root_dir)
50+
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
5151
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
5252
cls.patcher.start()
5353

test/datasets/test_imdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class TestIMDB(TempDirMixin, TorchtextTestCase):
5656
def setUpClass(cls):
5757
super().setUpClass()
5858
cls.root_dir = cls.get_base_temp_dir()
59-
cls.samples = _get_mock_dataset(cls.root_dir)
59+
cls.samples = _get_mock_dataset(os.path.join(cls.root_dir, "datasets"))
6060
cls.patcher = patch("torchdata.datapipes.iter.util.cacheholder._hash_check", return_value=True)
6161
cls.patcher.start()
6262

test/datasets/test_iwslt2016.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def tearDownClass(cls):
164164
def test_iwslt2016(self, split, src, tgt, dev_set, test_set):
165165

166166
with tempfile.TemporaryDirectory() as root_dir:
167-
expected_samples = _get_mock_dataset(root_dir, split, src, tgt, dev_set, test_set)
167+
expected_samples = _get_mock_dataset(os.path.join(root_dir, "datasets"), split, src, tgt, dev_set, test_set)
168168

169169
dataset = IWSLT2016(
170170
root=root_dir,
@@ -185,7 +185,9 @@ def test_iwslt2016_split_argument(self, split):
185185
language_pair = ("de", "en")
186186
valid_set = "tst2013"
187187
test_set = "tst2014"
188-
_ = _get_mock_dataset(root_dir, split, language_pair[0], language_pair[1], valid_set, test_set)
188+
_ = _get_mock_dataset(
189+
os.path.join(root_dir, "datasets"), split, language_pair[0], language_pair[1], valid_set, test_set
190+
)
189191
dataset1 = IWSLT2016(
190192
root=root_dir,
191193
split=split,

test/datasets/test_iwslt2017.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ def tearDownClass(cls):
155155
def test_iwslt2017(self, split, src, tgt):
156156

157157
with tempfile.TemporaryDirectory() as root_dir:
158-
expected_samples = _get_mock_dataset(root_dir, split, src, tgt, "dev2010", "tst2010")
158+
expected_samples = _get_mock_dataset(
159+
os.path.join(root_dir, "datasets"), split, src, tgt, "dev2010", "tst2010"
160+
)
159161

160162
dataset = IWSLT2017(root=root_dir, split=split, language_pair=(src, tgt))
161163

@@ -170,7 +172,9 @@ def test_iwslt2017_split_argument(self, split):
170172
language_pair = ("de", "en")
171173
valid_set = "dev2010"
172174
test_set = "tst2010"
173-
_ = _get_mock_dataset(root_dir, split, language_pair[0], language_pair[1], valid_set, test_set)
175+
_ = _get_mock_dataset(
176+
os.path.join(root_dir, "datasets"), split, language_pair[0], language_pair[1], valid_set, test_set
177+
)
174178
dataset1 = IWSLT2017(root=root_dir, split=split, language_pair=language_pair)
175179
(dataset2,) = IWSLT2017(root=root_dir, split=(split,), language_pair=language_pair)
176180

0 commit comments

Comments
 (0)