feat: started test suite
Browse files- pixi.toml +1 -3
- tests/simple_load.py +45 -0
pixi.toml
CHANGED
@@ -7,9 +7,7 @@ version = "0.1.0"
|
|
7 |
|
8 |
[tasks]
|
9 |
test = "python -m pytest tests/ -v"
|
10 |
-
test-
|
11 |
-
test-loading = "python tests/test_dataset_loading.py"
|
12 |
-
test-hf = "python tests/test_hf_loading.py"
|
13 |
|
14 |
[dependencies]
|
15 |
pandas = ">=2.2.3,<3"
|
|
|
7 |
|
8 |
[tasks]
|
9 |
test = "python -m pytest tests/ -v"
|
10 |
+
test-load = "python tests/simple_load.py"
|
|
|
|
|
11 |
|
12 |
[dependencies]
|
13 |
pandas = ">=2.2.3,<3"
|
tests/simple_load.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Test suite for loading shlokn/autogkb dataset from Hugging Face."""
|
2 |
+
|
3 |
+
import pytest
|
4 |
+
from datasets import load_dataset
|
5 |
+
|
6 |
+
|
7 |
+
def test_dataset_loads_successfully():
|
8 |
+
"""Test that the dataset loads without errors."""
|
9 |
+
try:
|
10 |
+
dataset = load_dataset("shlokn/autogkb")
|
11 |
+
assert dataset is not None
|
12 |
+
print(f"✓ Dataset loaded successfully")
|
13 |
+
print(f"✓ Splits: {list(dataset.keys())}")
|
14 |
+
print(f"✓ Total examples: {sum(len(split) for split in dataset.values())}")
|
15 |
+
except Exception as e:
|
16 |
+
pytest.fail(f"Failed to load dataset from Hugging Face: {e}")
|
17 |
+
|
18 |
+
|
19 |
+
def test_dataset_splits_exist():
|
20 |
+
"""Test that expected splits are present."""
|
21 |
+
dataset = load_dataset("shlokn/autogkb")
|
22 |
+
expected_splits = {'train', 'validation', 'test'}
|
23 |
+
actual_splits = set(dataset.keys())
|
24 |
+
assert expected_splits.issubset(actual_splits), f"Missing expected splits. Got: {actual_splits}"
|
25 |
+
|
26 |
+
|
27 |
+
def test_dataset_not_empty():
|
28 |
+
"""Test that each split contains data."""
|
29 |
+
dataset = load_dataset("shlokn/autogkb")
|
30 |
+
for split_name, split_data in dataset.items():
|
31 |
+
assert len(split_data) > 0, f"Split '{split_name}' is empty"
|
32 |
+
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
# Run quick test if script is executed directly
|
36 |
+
try:
|
37 |
+
dataset = load_dataset("shlokn/autogkb")
|
38 |
+
print(f"✓ Dataset loaded successfully")
|
39 |
+
print(f"✓ Splits: {list(dataset.keys())}")
|
40 |
+
print(f"✓ Total examples: {sum(len(split) for split in dataset.values())}")
|
41 |
+
print("\n✓ Basic dataset loading test passed!")
|
42 |
+
print("Run 'pytest test_hf_dataset.py -v' for comprehensive tests.")
|
43 |
+
except Exception as e:
|
44 |
+
print(f"✗ Failed to load dataset: {e}")
|
45 |
+
exit(1)
|