from hypothesis import assume, given, strategies as st
from pytest import raises  # type: ignore

from ppb_vector import Vector
from utils import angle_isclose, isclose, lengths, vectors


@given(v=vectors(), length=st.floats(max_value=0))
def test_scale_negative_length(v: Vector, length: float):
    """Test that Vector.scale_to raises ValueError on negative lengths."""
    assume(length < 0)
    with raises(ValueError):
        v.scale_to(length)


@given(x=vectors(), length=lengths())
def test_scale_to_length(x: Vector, length: float):
    """Test that the length of x.scale_to(length) is length.

    Additionally, scale_to may raise ZeroDivisionError if the vector is null.
    """
    try:
        assert isclose(x.scale_to(length).length, length)
    except ZeroDivisionError:
        assert x == (0, 0)


@given(x=vectors(), length=lengths())
def test_scale_aligned(x: Vector, length: float):
    """Test that x.scale_to(length) is aligned with x."""
    assume(length > 0)
    try:
        assert angle_isclose(x.scale_to(length).angle(x), 0)
    except ZeroDivisionError:
        assert x == (0, 0)

@@ -600,219 +600,105 @@
 ngth
-.%0A%0A    Additionally, scale_to may raise ZeroDivisionError if the vector is null.%0A    %22%22%22%0A    try:%0A        assert isclose(x.scale_to(length).length, length)%0A    except ZeroDivisionError:%0A        assert x == (0, 0
+ with x non-null.%22%22%22%0A    assume(x != (0, 0))%0A    assert isclose(x.scale_to(length).length, length
 )%0A%0A%0A
@@ -868,23 +868,26 @@
  %3E 0
-)%0A    try:%0A    
+ and x != (0, 0))%0A
     
@@ -943,61 +943,4 @@
  0)%0A
-    except ZeroDivisionError:%0A        assert x == (0, 0)%0A

Simplify length & alignment tests