@@ -549,6 +549,50 @@ def call_sync(
549549 assert excinfo .value .timeout == 0.01
550550
551551
552+ def test_request_does_not_double_remove_the_timeout_source_on_timeout () -> None :
553+ # The same bug already fixed in _wait_for_signal (see
554+ # test_inputcapture.py's test of the same name): on_timeout() returning
555+ # False already deregisters a one-shot GLib timeout source, so calling
556+ # GLib.source_remove on it again logs a real "Source ID N was not found
557+ # when attempting to remove it" warning. _request() had this fixed only
558+ # in its sibling, never here, even though _request is the far more
559+ # heavily used of the two (CreateSession, SelectDevices, Start, GetZones,
560+ # SetPointerBarriers all go through it) -- so this is the single most
561+ # realistic timeout scenario in the module: a consent dialog nobody
562+ # answers. The fake source_remove doesn't model an already-deregistered
563+ # source (it just clears pending_timeout either way), so only asserting
564+ # the call was never made catches this.
565+ class SilentConnection (FakeConnection ):
566+ def call_sync (
567+ self ,
568+ bus_name : Any ,
569+ object_path : Any ,
570+ interface : Any ,
571+ method : str ,
572+ parameters : FakeVariant | None ,
573+ reply_type : Any ,
574+ flags : Any ,
575+ timeout : Any ,
576+ cancellable : Any ,
577+ ) -> FakeReply :
578+ self .calls .append (
579+ (method , None if parameters is None else parameters .value )
580+ )
581+ if method == "Get" :
582+ return FakeReply ((self .version ,))
583+ return FakeReply (()) # accepted, but no Response ever fires
584+
585+ connection = SilentConnection ()
586+ with install_fake_gi (connection ):
587+ glib = sys .modules ["gi.repository.GLib" ]
588+ with mock .patch .object (glib , "source_remove" ) as source_remove :
589+ with pytest .raises (portal .PortalTimeoutError ):
590+ portal .RemoteDesktopSession .negotiate (
591+ connection = connection , timeout = 0.01
592+ )
593+ source_remove .assert_not_called ()
594+
595+
552596def test_close_closes_an_unclaimed_eis_fd () -> None :
553597 # The fd arrives dup'd and owned. If nobody ever reads `eis_fd` (so it
554598 # was never handed to a Sender, which would close it itself), nothing
0 commit comments