File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -55,12 +55,14 @@ def _create_stdin_eof_monitor(
5555 if not hasattr (select , "poll" ):
5656 return None # pragma: no cover
5757
58- try :
58+ # The remaining code uses select.poll() which is not available on Windows.
59+ # Coverage is exercised on non-Windows platforms only.
60+ try : # pragma: lax no cover
5961 fd = sys .stdin .buffer .fileno ()
60- except Exception :
62+ except Exception : # pragma: lax no cover
6163 return None
6264
63- async def monitor () -> None :
65+ async def monitor () -> None : # pragma: lax no cover
6466 poll_obj = select .poll ()
6567 poll_obj .register (fd , select .POLLIN | select .POLLHUP )
6668 try :
@@ -74,7 +76,7 @@ async def monitor() -> None:
7476 finally :
7577 poll_obj .unregister (fd )
7678
77- return monitor
79+ return monitor # pragma: lax no cover
7880
7981
8082@asynccontextmanager
@@ -131,6 +133,6 @@ async def stdout_writer():
131133
132134 eof_monitor = _create_stdin_eof_monitor (tg )
133135 if eof_monitor is not None :
134- tg .start_soon (eof_monitor )
136+ tg .start_soon (eof_monitor ) # pragma: lax no cover
135137
136138 yield read_stream , write_stream
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ def test_create_stdin_eof_monitor_returns_none_when_fileno_fails():
8484
8585@pytest .mark .anyio
8686@pytest .mark .skipif (sys .platform == "win32" , reason = "select.poll not available on Windows" )
87- async def test_stdin_eof_monitor_detects_hangup ():
87+ async def test_stdin_eof_monitor_detects_hangup (): # pragma: lax no cover
8888 """The EOF monitor cancels the task group when stdin pipe closes."""
8989 read_fd , write_fd = os .pipe ()
9090 try :
@@ -106,14 +106,14 @@ async def test_stdin_eof_monitor_detects_hangup():
106106 while not tg .cancel_scope .cancel_called :
107107 await anyio .sleep (0.05 )
108108 finally :
109- os .close (read_fd ) # pragma: no cover
110- if write_fd != - 1 : # pragma: no cover
109+ os .close (read_fd )
110+ if write_fd != - 1 :
111111 os .close (write_fd )
112112
113113
114114@pytest .mark .anyio
115115@pytest .mark .skipif (sys .platform == "win32" , reason = "select.poll not available on Windows" )
116- async def test_stdin_eof_monitor_ignores_pollin_events ():
116+ async def test_stdin_eof_monitor_ignores_pollin_events (): # pragma: lax no cover
117117 """The monitor ignores POLLIN events (data available) and only reacts to hangup/error."""
118118 read_fd , write_fd = os .pipe ()
119119 try :
@@ -144,6 +144,6 @@ async def test_stdin_eof_monitor_ignores_pollin_events():
144144 while not tg .cancel_scope .cancel_called : # pragma: no branch
145145 await anyio .sleep (0.05 )
146146 finally :
147- os .close (read_fd ) # pragma: no cover
148- if write_fd != - 1 : # pragma: no cover
147+ os .close (read_fd )
148+ if write_fd != - 1 :
149149 os .close (write_fd )
You can’t perform that action at this time.
0 commit comments