|
Download code/code202.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/034ba678829a1c436b19d43dd3adab33b5170a80/code/code202.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@034ba678829a1c436b19d43dd3adab33b5170a80/code/code202.jsonl
-
curl -L -o code202.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/034ba678829a1c436b19d43dd3adab33b5170a80/code/code202.jsonl
1.95 kB
| {"type": "session", "harness": "deepseek-harness", "id": "code202", "name": "Python testing with pytest"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}} | |
| {"type": "message", "message": {"role": "user", "content": "How do I write good tests with pytest?"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Basic Structure:**\n```python\nimport pytest\n\ndef test_addition():\n assert 1 + 1 == 2\n\nclass TestCalculator:\n def test_divide(self):\n assert 10 / 2 == 5\n```\n\n**Fixtures:**\n```python\n@pytest.fixture\ndef sample_data():\n return {\"users\": [{\"id\": 1, \"name\": \"Alice\"}]}\n\ndef test_users(sample_data):\n assert len(sample_data[\"users\"]) == 1\n```\n\n**Parametrization:**\n```python\n@pytest.mark.parametrize(\"a,b,expected\", [\n (1, 2, 3),\n (0, 0, 0),\n (-1, 1, 0),\n])\ndef test_add(a, b, expected):\n assert a + b == expected\n```\n\n**Mocking:**\n```python\nfrom unittest.mock import Mock, patch\n\n@patch(\"my_module.external_api\")\ndef test_with_mock(mock_api):\n mock_api.return_value = {\"status\": \"ok\"}\n result = my_module.call_api()\n assert result[\"status\"] == \"ok\"\n```\n\n**Async Testing:**\n```python\n@pytest.mark.asyncio\nasync def test_async():\n result = await async_function()\n assert result == \"expected\"\n```\n\n**Coverage:**\n```bash\npytest --cov=my_package --cov-report=html\n```\n\n**Tips:**\n- One assertion per test\n- Descriptive test names\n- Use fixtures for setup/teardown\n- Mock external dependencies\n- Run tests in CI/CD"}} | |