Skip to content
Back to skills

Verify With Inline Tests

ASecurity

For test co-location: tests in same file as code, run with main, tests as documentation and examples.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 7, 2026
ai-agentspythonci/cddocumentation

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add jimmc414/claude-code-plugin-marketplace --skill verify-with-inline-tests --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Verify With Inline Tests?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Verify With Inline Tests
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jimmc414-verify-with-inline-tests/badge)](https://www.skillsdirectory.com/skills/jimmc414-verify-with-inline-tests)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: verify-with-inline-tests
description: "For test co-location: tests in same file as code, run with main, tests as documentation and examples."
---

# verify-with-inline-tests

## When to Use
- Tests should be near the code
- Tests serve as documentation
- Single-file modules
- Quick verification during development

## When NOT to Use
- Large test suites
- Need test isolation
- CI/CD expects tests in specific location

## The Pattern

Include tests in the module, run them when module is executed directly.

```python
def my_function(x):
    """Do something useful."""
    return x * 2

def test():
    """Run all tests."""
    assert my_function(2) == 4
    assert my_function(0) == 0
    assert my_function(-1) == -2
    print("All tests pass.")

if __name__ == '__main__':
    test()
```

## Example (from pytudes)

```python
# sudoku.py - structural invariant tests
def test():
    """A set of tests that must pass."""
    assert len(squares) == 81
    assert len(unitlist) == 27
    assert all(len(units[s]) == 3 for s in squares)
    assert all(len(peers[s]) == 20 for s in squares)
    assert units['C2'] == [
        ['A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2', 'I2'],
        ['C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9'],
        ['A1', 'A2', 'A3', 'B1', 'B2', 'B3', 'C1', 'C2', 'C3']
    ]
    print('All tests pass.')

if __name__ == '__main__':
    test()
    solve_all(open("sudoku-easy50.txt"), "easy")
    solve_all(open("sudoku-top95.txt"), "hard")

# spell.py - comprehensive unit tests
def unit_tests():
    assert correction('speling') == 'spelling'
    assert correction('korrectud') == 'corrected'
    assert correction('bycycle') == 'bicycle'
    assert words('This is a TEST.') == ['this', 'is', 'a', 'test']
    assert len(WORDS) == 32198
    assert sum(WORDS.values()) == 1115585
    assert 0.07 < P('the') < 0.08
    return 'unit_tests pass'

if __name__ == '__main__':
    print(unit_tests())
    spelltest(Testset(open('spell-testset1.txt')))
```

## Key Principles
1. **`if __name__ == '__main__'`**: Only run tests when executed directly
2. **Assert for tests**: Simple, clear assertions
3. **Print success**: Confirm tests ran
4. **Test structure first**: Validate data structures built correctly
5. **Tests as examples**: Show how functions are used

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.