File: test_coverage_edge_cases.py

package info (click to toggle)
awesomeversion 25.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,304 kB
  • sloc: python: 2,411; sh: 146; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Tests for edge cases to ensure 100% code coverage."""

from __future__ import annotations

from unittest.mock import patch

from awesomeversion import AwesomeVersion, AwesomeVersionStrategy
from awesomeversion.utils.regex import get_compiled_pattern


def test_hexver_modifier_type() -> None:
    """Test that HexVer strategy returns None for modifier_type."""
    av = AwesomeVersion("0xABCD")
    assert av.strategy == AwesomeVersionStrategy.HEXVER
    assert av.modifier_type is None


def test_get_compiled_pattern_missing() -> None:
    """Test get_compiled_pattern with non-existent pattern name."""
    result = get_compiled_pattern("NON_EXISTENT_PATTERN")
    assert result is None


def test_buildver_section_valueerror() -> None:
    """Test BuildVer section method ValueError handling."""
    av = AwesomeVersion("123")
    assert av.strategy == AwesomeVersionStrategy.BUILDVER

    # Mock the string property to return something that will cause ValueError in int()
    with patch.object(
        type(av), "string", new_callable=lambda: property(lambda self: "not_a_number")
    ):
        result = av.section(0)
        assert result == 0  # Should return 0 due to ValueError