一键导入
testing-patterns
Testing conventions, patterns, and best practices for IterableData. Use when writing tests, debugging test failures, or establishing test coverage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Testing conventions, patterns, and best practices for IterableData. Use when writing tests, debugging test failures, or establishing test coverage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
AI and LLM integration for IterableData. Use when working with iterable.ai, autodoc, LLM providers, catalog, or agent-facing APIs.
Guide for implementing new data formats in IterableData. Use when adding support for new file formats, compression codecs, or extending format capabilities.
Guide for implementing database engines in IterableData. Use when adding support for new SQL or NoSQL databases, implementing DBDriver classes, or extending database capabilities.
Core development workflows, patterns, and conventions for IterableData. Use when implementing features, fixing bugs, or working with the codebase structure.
OpenSpec proposal creation, validation, and implementation workflows. Use when creating change proposals, implementing specs, or working with OpenSpec conventions.
| name | testing-patterns |
| description | Testing conventions, patterns, and best practices for IterableData. Use when writing tests, debugging test failures, or establishing test coverage. |
test_*.py in tests/ directorytest_csv.py, test_parquet.pyTest* (e.g., TestCSV, TestParquet)test_* (e.g., test_read, test_write)# All tests
pytest --verbose
# Specific test file
pytest tests/test_csv.py -v
# Specific test function
pytest tests/test_csv.py::TestCSV::test_read -v
# Parallel execution
pytest -n auto
# With coverage
pytest --cov=iterable --cov-report=html
def test_read(self):
with open_iterable('testdata/test.csv') as source:
rows = list(source)
assert len(rows) > 0
assert isinstance(rows[0], dict)
def test_write(self, tmp_path):
output = tmp_path / 'output.csv'
data = [{'col1': 'val1', 'col2': 'val2'}]
with open_iterable(output, 'w') as dest:
dest.write_bulk(data)
# Verify written data
with open_iterable(output) as source:
rows = list(source)
assert rows == data
def test_gzip_compression(self):
with open_iterable('testdata/test.csv.gz') as source:
rows = list(source)
assert len(rows) > 0
def test_read_bulk(self):
with open_iterable('testdata/test.csv') as source:
chunks = list(source.read_bulk(size=100))
assert len(chunks) > 0
assert all(isinstance(chunk, list) for chunk in chunks)
def test_empty_file(self):
with open_iterable('testdata/empty.csv') as source:
rows = list(source)
assert rows == []
def test_malformed_data(self):
with pytest.raises(ValueError):
with open_iterable('testdata/malformed.csv') as source:
list(source)
@pytest.mark.skipif(
not HAS_OPTIONAL_DEPENDENCY,
reason="Optional dependency not installed"
)
def test_optional_format(self):
# Test format that requires optional dependency
pass
testdata/ directorytest_simple.csv, test_nested.json.gz, .bz2, .zst, etc.pytest --cov=iterable --cov-report=html
# Opens htmlcov/index.html
class TestCSV:
def test_read(self):
pass
def test_write(self):
pass
def test_read_bulk(self):
pass
Use pytest fixtures for common setup:
@pytest.fixture
def sample_data():
return [{'col1': 'val1', 'col2': 'val2'}]
def test_write_with_fixture(sample_data, tmp_path):
output = tmp_path / 'output.csv'
with open_iterable(output, 'w') as dest:
dest.write_bulk(sample_data)
Tests should pass for:
Use pytest markers if version-specific behavior needed:
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Requires Python 3.11+"
)
with open_iterable(...) as source:tmp_path fixture for write tests@pytest.mark.skipif appropriatelydef test_round_trip(self, tmp_path):
original = [{'a': 1, 'b': 2}, {'a': 3, 'b': 4}]
output = tmp_path / 'output.csv'
# Write
with open_iterable(output, 'w') as dest:
dest.write_bulk(original)
# Read back
with open_iterable(output) as source:
result = list(source)
assert result == original
def test_streaming(self):
with open_iterable('large_file.csv') as source:
count = 0
for row in source:
count += 1
if count >= 100:
break
assert count == 100
pytest -vv # Very verbose
pytest -s # Show print statements
pytest --lf # Last failed
pytest --ff # Failed first
pytest tests/test_csv.py::TestCSV::test_read -v -s