tinycodinglm / code /bad008.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 12)
3c88a0f verified
|
Raw History Blame
2.35 kB
deepseek-harness trace
System 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 c...

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.

User

What are bad testing practices?

Assistant

Bad Testing Habits:

  1. No Tests At All:
python
# Bad: ship and pray
def calculate_total(items):
    return sum(i.price for i in items)  # hope it works

# Good: write tests first
def test_calculate_total():
    items = [Item(price=10), Item(price=20)]
    assert calculate_total(items) == 30
  1. Testing Implementation, Not Behavior:
python
# Bad: tests internal calls
def test_user_creation():
    user = User("test")
    assert user._generate_id() is not None  # tests private method

# Good: tests public behavior
def test_user_creation():
    user = User("test")
    assert user.is_valid()
  1. Test Interdependence:
python
# Bad: tests depend on order
def test_create_user():
    global user
    user = create_user("test")

def test_delete_user():
    user.delete()  # fails if test_create_user not run first
  1. Ignoring Failures:
python
# Bad
try:
    assert result == expected
except AssertionError:
    pass  # just ignore failures

# Good: fix or mark as known issue
@pytest.mark.xfail(reason="Bug #123")
def test_known_bug():
    assert buggy_function() == expected
  1. No Edge Case Testing:
python
# Bad: only happy path
def test_divide():
    assert divide(10, 2) == 5

# Good: test edge cases
def test_divide():
    assert divide(10, 2) == 5
    assert divide(0, 1) == 0
    assert divide(-1, 1) == -1
    with pytest.raises(ZeroDivisionError):
        divide(10, 0)
  1. Tests That Take Too Long:
  • Slow tests get skipped
  • Keep unit tests under 100ms
  • Integration tests separate from unit tests