summaryrefslogtreecommitdiff
path: root/src/tox/execute
diff options
context:
space:
mode:
authorBernát Gábor <bgabor8@bloomberg.net>2020-12-28 00:16:42 +0000
committerBernát Gábor <bgabor8@bloomberg.net>2020-12-28 00:16:42 +0000
commit69d33d10d84974d427c44823c3fefb5973209568 (patch)
treef40698c7f1c2fd364e02fb0e8f65ff54cf7a3a5f /src/tox/execute
parentd2c2322eeec0889a5e0c25301b9c9ab5be00b7b4 (diff)
downloadtox-git-69d33d10d84974d427c44823c3fefb5973209568.tar.gz
Improve coverage
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
Diffstat (limited to 'src/tox/execute')
-rw-r--r--src/tox/execute/local_sub_process/__init__.py14
-rw-r--r--src/tox/execute/local_sub_process/read_via_thread_unix.py10
-rw-r--r--src/tox/execute/local_sub_process/read_via_thread_windows.py4
3 files changed, 14 insertions, 14 deletions
diff --git a/src/tox/execute/local_sub_process/__init__.py b/src/tox/execute/local_sub_process/__init__.py
index ff0a48d4..8e225abc 100644
--- a/src/tox/execute/local_sub_process/__init__.py
+++ b/src/tox/execute/local_sub_process/__init__.py
@@ -60,7 +60,7 @@ class LocalSubprocessExecuteStatus(ExecuteStatus):
def write_stdin(self, content: str) -> None:
stdin = self._process.stdin
- if stdin is not None:
+ if stdin is not None: # pragma: no branch
bytes_content = content.encode()
if sys.platform == "win32": # pragma: win32 cover
# on Windows we have a PipeHandle object here rather than a file stream
@@ -77,7 +77,7 @@ class LocalSubprocessExecuteStatus(ExecuteStatus):
def close_stdin(self) -> None:
stdin = self._process.stdin
- if stdin is not None:
+ if stdin is not None: # pragma: no branch
stdin.close()
def __repr__(self) -> str:
@@ -212,18 +212,18 @@ class LocalSubProcessExecuteInstance(ExecuteInstance):
out, err = proc.communicate() # just drain
except ValueError: # if already drained via another communicate
out, err = b"", b""
- if out:
+ if out: # pragma: no branch
self.out_handler(out)
- if err:
- self.err_handler(err)
+ if err: # pragma: no branch
+ self.err_handler(err) # pragma: no cover
return int(self.process.returncode)
return Outcome.OK # pragma: no cover
def set_out_err(self, out: SyncWrite, err: SyncWrite) -> Tuple[SyncWrite, SyncWrite]:
prev = self._out, self._err
- if self._read_stdout is not None:
+ if self._read_stdout is not None: # pragma: no branch
self._read_stdout.handler = out.handler
- if self._read_stderr is not None:
+ if self._read_stderr is not None: # pragma: no branch
self._read_stderr.handler = err.handler
return prev
diff --git a/src/tox/execute/local_sub_process/read_via_thread_unix.py b/src/tox/execute/local_sub_process/read_via_thread_unix.py
index ec2f0640..807ef0b3 100644
--- a/src/tox/execute/local_sub_process/read_via_thread_unix.py
+++ b/src/tox/execute/local_sub_process/read_via_thread_unix.py
@@ -19,14 +19,14 @@ class ReadViaThreadUnix(ReadViaThread): # pragma: win32 no cover
while not self.stop.is_set():
# we need to drain the stream, but periodically give chance for the thread to break if the stop event has
# been set (this is so that an interrupt can be handled)
- if self._read_available() is None:
- break
+ if self._read_available() is None: # pragma: no branch
+ break # pragma: no cover
def _drain_stream(self) -> None:
# no block just poll
while True:
- if self._read_available(timeout=0) is not True:
- break
+ if self._read_available(timeout=0) is not True: # pragma: no branch
+ break # pragma: no cover
def _read_available(self, timeout: float = STOP_EVENT_CHECK_PERIODICITY_IN_MS) -> Optional[bool]:
try:
@@ -38,7 +38,7 @@ class ReadViaThreadUnix(ReadViaThread): # pragma: win32 no cover
self.handler(data)
return True
return False
- except OSError as exception:
+ except OSError as exception: # pragma: no cover
# Bad file descriptor or Input/output error
if exception.errno in (errno.EBADF, errno.EIO):
return None
diff --git a/src/tox/execute/local_sub_process/read_via_thread_windows.py b/src/tox/execute/local_sub_process/read_via_thread_windows.py
index 4f37f83d..9bec8962 100644
--- a/src/tox/execute/local_sub_process/read_via_thread_windows.py
+++ b/src/tox/execute/local_sub_process/read_via_thread_windows.py
@@ -1,9 +1,9 @@
"""
On Windows we use overlapped mechanism, borrowing it from asyncio (but without the event loop).
"""
-import logging
+import logging # pragma: win32 cover
from asyncio.windows_utils import BUFSIZE # pragma: win32 cover
-from time import sleep
+from time import sleep # pragma: win32 cover
from typing import Callable, Optional # pragma: win32 cover
import _overlapped # type: ignore[import] # pragma: win32 cover