Files
slic/tests/test_string_utils.py
T
tligui_y 57d063c492
Run Pytest with Allure and Coverage Reports / tests (push) Successful in 42s
Update tests/test_string_utils.py
2025-07-15 11:09:55 +02:00

44 lines
1.3 KiB
Python

import pytest
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from functions.string_utils import *
import warnings
def test_uppercase_normal():
# Normal string uppercase conversion
assert uppercase("hello") == "HELLO"
def test_uppercase_type_error():
# TypeError when input is None (invalid input)
uppercase(None)
def test_reverse_string():
# Tests string reversal correctness
assert reverse("abc") == "cba"
def test_warning_emit():
# Emits a Python UserWarning
warnings.warn("Test warning", UserWarning)
def test_unicode_decode_error():
# UnicodeDecodeError when decoding invalid byte sequence
b'\xff'.decode('utf-8')
def test_unicode_decode_surrogateescape():
# UnicodeDecodeError with strict error handler on invalid byte
b"\x80".decode("utf-8", errors="strict")
def test_import_warning():
# Emit ImportWarning (sera dans warnings du rapport)
warnings.warn("Import warning", ImportWarning)
@pytest.mark.xfail(reason="Expected failure: uppercase does not handle digits")
def test_xfail_uppercase_digits():
# Expected fail test because uppercase won't change digits
assert uppercase("abc123") == "ABC1234"
def test_keyboard_interrupt_direct():
# Directly raise KeyboardInterrupt exception
raise KeyboardInterrupt()