diff --git a/tests/conftest.py b/tests/conftest.py index 9380fd9..759787c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,7 +13,7 @@ def real_run_fixture(pytestconfig) -> Iterator[None]: else: with patch("winrt.windows.ui.notifications.ToastNotificationManager.create_toast_notifier"), patch( "winrt.windows.ui.notifications.ToastNotifier.show" - ), patch("winrt.windows.ui.notifications.ToastNotificationHistory.clear"): + ), patch("winrt.windows.ui.notifications.ToastNotificationHistory.clear"), patch("time.sleep"): yield diff --git a/tests/test_toasts.py b/tests/test_toasts.py index 5b3120f..2073538 100644 --- a/tests/test_toasts.py +++ b/tests/test_toasts.py @@ -297,15 +297,24 @@ def test_system_toast(): InteractableWindowsToaster("Python").show_toast(newToast) + def test_remove_toast(): toaster = WindowsToaster("Python") - newToast = Toast(["Disappearing act"]) - newToast.on_dismissed = lambda _: toaster.remove_toast(newToast) toaster.show_toast(newToast) + import time + + time.sleep(0.5) + + toaster.remove_toast(newToast) + + def test_remove_toast_group(): + import time + from src.windows_toasts import ToastActivatedEventArgs + toaster = WindowsToaster("Python") toast1 = Toast(["A bigger disappearing act"], group="begone") @@ -315,3 +324,8 @@ def test_remove_toast_group(): toaster.show_toast(toast1) toaster.show_toast(toast2) + + # If it hasn't been activated, remove it ourselves + time.sleep(1) + + toast2.on_activated(ToastActivatedEventArgs())