Skip to content

Commit

Permalink
Add # pragma: no cover to a few places which cover edge cases
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Jul 2, 2023
1 parent 8ef50da commit c483337
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pytestshellutils/customtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EnvironDict(Dict[str, str]):
Environ dictionary type.
"""

def __str__(self) -> str:
def __str__(self) -> str: # pragma: no cover
"""
String representation of the class.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/pytestshellutils/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def format_callback_to_string(
return callback_str


def warn_until(
def warn_until( # pragma: no cover
version: str,
message: str,
category: Type[Warning] = DeprecationWarning,
Expand Down
4 changes: 2 additions & 2 deletions src/pytestshellutils/utils/ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_unused_localhost_port(use_cache: bool = False) -> int:
use_cache:
If ``use_cache`` is ``True``, consecutive calls to this function will never return the cached port.
"""
if not isinstance(use_cache, bool):
if not isinstance(use_cache, bool): # pragma: no cover
raise pytest.UsageError(
f"The value of 'use_cache' needs to be an boolean, not {type(use_cache)}"
)
Expand Down Expand Up @@ -65,6 +65,6 @@ def get_connectable_ports(ports: Iterable[int]) -> Set[int]:
log.debug("Port %s is connectable!", port)
connectable_ports.add(port)
sock.shutdown(socket.SHUT_RDWR)
except OSError:
except OSError: # pragma: no cover
continue
return connectable_ports
10 changes: 5 additions & 5 deletions src/pytestshellutils/utils/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

try:
from pytest import LineMatcher
except ImportError:
except ImportError: # pragma: no cover
# Older pytest
from _pytest.pytester import LineMatcher

Expand Down Expand Up @@ -113,7 +113,7 @@ def _default_data(self) -> Optional[Dict[Any, Any]]:
return None

@property
def exitcode(self) -> int:
def exitcode(self) -> int: # pragma: no cover
"""
Return the process returncode.
Expand All @@ -129,7 +129,7 @@ def exitcode(self) -> int:
return self.returncode

@property
def json(self) -> Optional[Dict[Any, Any]]:
def json(self) -> Optional[Dict[Any, Any]]: # pragma: no cover
"""
Return the process output parsed as JSON, if possible.
Expand Down Expand Up @@ -195,7 +195,7 @@ def _get_cmdline(proc: psutil.Process) -> Optional[Any]:
# and we use it in log calls
try:
cmdline = proc.cmdline()
except (psutil.NoSuchProcess, psutil.AccessDenied):
except (psutil.NoSuchProcess, psutil.AccessDenied): # pragma: no cover
# OSX is more restrictive about the above information
cmdline = None
except OSError: # pragma: no cover
Expand Down Expand Up @@ -237,7 +237,7 @@ def _get_cmdline(proc: psutil.Process) -> Optional[Any]:
# c: ... \lib\site-packages\psutil\_pswindows.py:806: RuntimeError
cmdline = None

if not cmdline:
if not cmdline: # pragma: no cover
try:
cmdline = proc.as_dict()
except psutil.NoSuchProcess:
Expand Down

0 comments on commit c483337

Please sign in to comment.