tw1_factorial_BEGIN
```python
import pytest
from mymodule import factorial


def test_factorial_zero():
    assert factorial(0) == 1


def test_factorial_one():
    assert factorial(1) == 1


def test_factorial_small():
    assert factorial(5) == 120


def test_factorial_larger():
    assert factorial(10) == 3628800


def test_factorial_negative_raises():
    with pytest.raises(ValueError, match="n must be non-negative"):
        factorial(-1)
```
tw1_factorial_END

tw2_clamp_BEGIN
```python
import pytest
from mymodule import clamp


def test_clamp_within_range():
    assert clamp(5.0, 0.0, 10.0) == 5.0


def test_clamp_below_lo():
    assert clamp(-1.0, 0.0, 10.0) == 0.0


def test_clamp_above_hi():
    assert clamp(15.0, 0.0, 10.0) == 10.0


def test_clamp_equal_to_lo():
    assert clamp(0.0, 0.0, 10.0) == 0.0


def test_clamp_equal_to_hi():
    assert clamp(10.0, 0.0, 10.0) == 10.0


def test_clamp_lo_equals_hi():
    assert clamp(5.0, 3.0, 3.0) == 3.0


def test_clamp_invalid_range_raises():
    with pytest.raises(ValueError, match="lo must not exceed hi"):
        clamp(5.0, 10.0, 0.0)
```
tw2_clamp_END

tw3_word_count_BEGIN
```python
import pytest
from mymodule import word_count


def test_word_count_simple():
    assert word_count("hello world") == {"hello": 1, "world": 1}


def test_word_count_repeated_words():
    assert word_count("foo bar foo") == {"foo": 2, "bar": 1}


def test_word_count_case_insensitive():
    assert word_count("Hello HELLO hello") == {"hello": 3}


def test_word_count_empty_string():
    assert word_count("") == {}


def test_word_count_whitespace_only():
    assert word_count("   ") == {}


def test_word_count_multiple_whitespace():
    assert word_count("a  b\tc\nd") == {"a": 1, "b": 1, "c": 1, "d": 1}
```
tw3_word_count_END

tw4_trivial_one_assert_BEGIN
```python
import pytest
from mymodule import double


def test_double_positive():
    assert double(3) == 6


def test_double_zero():
    assert double(0) == 0


def test_double_negative():
    assert double(-4) == -8
```
tw4_trivial_one_assert_END

tw5_validate_email_BEGIN
```python
import pytest
from mymodule import is_valid_email


@pytest.mark.parametrize("email", [
    "user@example.com",
    "first.last@example.co.uk",
    "user+tag@example.com",
    "user_name@sub.example.org",
    "a1b2@test.io",
])
def test_valid_emails(email):
    assert is_valid_email(email) is True


@pytest.mark.parametrize("email", [
    "",
    "plainaddress",
    "@example.com",
    "user@",
    "user@.com",
    "user@example",
    "user@example.c",
    "user @example.com",
    "user@example .com",
])
def test_invalid_emails(email):
    assert is_valid_email(email) is False
```
tw5_validate_email_END

tw6_remove_negatives_BEGIN
```python
import pytest
from mymodule import remove_negatives


def test_remove_negatives_mixed():
    assert remove_negatives({"a": 1, "b": -1, "c": 2, "d": -5}) == {"a": 1, "c": 2}


def test_remove_negatives_all_positive():
    assert remove_negatives({"a": 1, "b": 2}) == {"a": 1, "b": 2}


def test_remove_negatives_all_negative():
    assert remove_negatives({"a": -1, "b": -2}) == {}


def test_remove_negatives_empty():
    assert remove_negatives({}) == {}


def test_remove_negatives_zero_kept():
    assert remove_negatives({"a": 0, "b": -1}) == {"a": 0}


def test_remove_negatives_floats():
    assert remove_negatives({"a": 1.5, "b": -0.1, "c": 0.0}) == {"a": 1.5, "c": 0.0}
```
tw6_remove_negatives_END

tw7_async_fetch_BEGIN
```python
import pytest
import httpx
from mymodule import fetch_user


@pytest.mark.asyncio
async def test_fetch_user_success():
    def handler(request: httpx.Request) -> httpx.Response:
        assert request.url.path == "/users/42"
        return httpx.Response(200, json={"id": 42, "name": "Alice"})

    transport = httpx.MockTransport(handler)
    async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
        result = await fetch_user(42, client)
    assert result == {"id": 42, "name": "Alice"}


@pytest.mark.asyncio
async def test_fetch_user_404_raises():
    def handler(request: httpx.Request) -> httpx.Response:
        return httpx.Response(404)

    transport = httpx.MockTransport(handler)
    async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
        with pytest.raises(httpx.HTTPStatusError):
            await fetch_user(1, client)


@pytest.mark.asyncio
async def test_fetch_user_500_raises():
    def handler(request: httpx.Request) -> httpx.Response:
        return httpx.Response(500)

    transport = httpx.MockTransport(handler)
    async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
        with pytest.raises(httpx.HTTPStatusError):
            await fetch_user(1, client)
```
tw7_async_fetch_END

tw8_sort_stable_BEGIN
```python
import pytest
from mymodule import sort_by_priority


def test_sort_by_priority_basic():
    assert sort_by_priority([(3, "c"), (1, "a"), (2, "b")]) == [(1, "a"), (2, "b"), (3, "c")]


def test_sort_by_priority_empty():
    assert sort_by_priority([]) == []


def test_sort_by_priority_single():
    assert sort_by_priority([(5, "x")]) == [(5, "x")]


def test_sort_by_priority_stable():
    items = [(1, "first"), (2, "a"), (1, "second"), (2, "b"), (1, "third")]
    result = sort_by_priority(items)
    assert result == [(1, "first"), (1, "second"), (1, "third"), (2, "a"), (2, "b")]


def test_sort_by_priority_negative_priorities():
    assert sort_by_priority([(0, "z"), (-1, "y"), (1, "x")]) == [(-1, "y"), (0, "z"), (1, "x")]


def test_sort_by_priority_does_not_mutate():
    items = [(2, "b"), (1, "a")]
    original = list(items)
    sort_by_priority(items)
    assert items == original
```
tw8_sort_stable_END
