From 9cb763e83a7435b48b9a47e7fa0aaa9b9bb27ffb Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 22 Feb 2018 09:42:43 -0800 Subject: [PATCH] add "pragma: no cover" to set_trace() and debug code we've got some tests to exercise this, so it shouldn't bitrot completely, but there are some branches-not-taken warnings that I think are spurious --- src/wormhole/_allocator.py | 2 +- src/wormhole/_boss.py | 2 +- src/wormhole/_code.py | 2 +- src/wormhole/_input.py | 4 ++-- src/wormhole/_key.py | 4 ++-- src/wormhole/_lister.py | 2 +- src/wormhole/_mailbox.py | 2 +- src/wormhole/_nameplate.py | 2 +- src/wormhole/_order.py | 2 +- src/wormhole/_receive.py | 2 +- src/wormhole/_rlcompleter.py | 2 +- src/wormhole/_send.py | 2 +- src/wormhole/_terminator.py | 4 ++-- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/wormhole/_allocator.py b/src/wormhole/_allocator.py index 399ced8..3c98f10 100644 --- a/src/wormhole/_allocator.py +++ b/src/wormhole/_allocator.py @@ -10,7 +10,7 @@ from . import _interfaces class Allocator(object): _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def wire(self, rendezvous_connector, code): self._RC = _interfaces.IRendezvousConnector(rendezvous_connector) diff --git a/src/wormhole/_boss.py b/src/wormhole/_boss.py index b18ba2d..33c00e2 100644 --- a/src/wormhole/_boss.py +++ b/src/wormhole/_boss.py @@ -37,7 +37,7 @@ class Boss(object): _tor = attrib(validator=optional(provides(_interfaces.ITorManager))) _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __attrs_post_init__(self): self._build_workers() diff --git a/src/wormhole/_code.py b/src/wormhole/_code.py index eb706ba..96314b2 100644 --- a/src/wormhole/_code.py +++ b/src/wormhole/_code.py @@ -21,7 +21,7 @@ def first(outputs): class Code(object): _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def wire(self, boss, allocator, nameplate, key, input): self._B = _interfaces.IBoss(boss) diff --git a/src/wormhole/_input.py b/src/wormhole/_input.py index 56e0f96..7c4f74a 100644 --- a/src/wormhole/_input.py +++ b/src/wormhole/_input.py @@ -19,7 +19,7 @@ def first(outputs): class Input(object): _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __attrs_post_init__(self): self._all_nameplates = set() @@ -30,7 +30,7 @@ class Input(object): def set_debug(self, f): self._trace = f - def _debug(self, what): + def _debug(self, what): # pragma: no cover if self._trace: self._trace(old_state="", input=what, new_state="") diff --git a/src/wormhole/_key.py b/src/wormhole/_key.py index 3ad3efc..f76f454 100644 --- a/src/wormhole/_key.py +++ b/src/wormhole/_key.py @@ -64,7 +64,7 @@ class Key(object): _side = attrib(validator=instance_of(type(u""))) _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __attrs_post_init__(self): self._SK = _SortedKey(self._appid, self._versions, self._side, @@ -115,7 +115,7 @@ class _SortedKey(object): _side = attrib(validator=instance_of(type(u""))) _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def wire(self, boss, mailbox, receive): self._B = _interfaces.IBoss(boss) diff --git a/src/wormhole/_lister.py b/src/wormhole/_lister.py index 0478046..ebe7919 100644 --- a/src/wormhole/_lister.py +++ b/src/wormhole/_lister.py @@ -10,7 +10,7 @@ from . import _interfaces class Lister(object): _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def wire(self, rendezvous_connector, input): self._RC = _interfaces.IRendezvousConnector(rendezvous_connector) diff --git a/src/wormhole/_mailbox.py b/src/wormhole/_mailbox.py index db52d36..36167e6 100644 --- a/src/wormhole/_mailbox.py +++ b/src/wormhole/_mailbox.py @@ -10,7 +10,7 @@ from . import _interfaces class Mailbox(object): _side = attrib(validator=instance_of(type(u""))) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __attrs_post_init__(self): self._mailbox = None diff --git a/src/wormhole/_nameplate.py b/src/wormhole/_nameplate.py index 244c635..b0d673c 100644 --- a/src/wormhole/_nameplate.py +++ b/src/wormhole/_nameplate.py @@ -15,7 +15,7 @@ def validate_nameplate(nameplate): @implementer(_interfaces.INameplate) class Nameplate(object): m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __init__(self): self._nameplate = None diff --git a/src/wormhole/_order.py b/src/wormhole/_order.py index 31377cb..e2128df 100644 --- a/src/wormhole/_order.py +++ b/src/wormhole/_order.py @@ -11,7 +11,7 @@ class Order(object): _side = attrib(validator=instance_of(type(u""))) _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __attrs_post_init__(self): self._key = None diff --git a/src/wormhole/_receive.py b/src/wormhole/_receive.py index 8cb88c2..4fa2858 100644 --- a/src/wormhole/_receive.py +++ b/src/wormhole/_receive.py @@ -12,7 +12,7 @@ class Receive(object): _side = attrib(validator=instance_of(type(u""))) _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __attrs_post_init__(self): self._key = None diff --git a/src/wormhole/_rlcompleter.py b/src/wormhole/_rlcompleter.py index c717ed1..853b98f 100644 --- a/src/wormhole/_rlcompleter.py +++ b/src/wormhole/_rlcompleter.py @@ -14,7 +14,7 @@ from .errors import KeyFormatError, AlreadyInputNameplateError errf = None # uncomment this to enable tab-completion debugging #import os ; errf = open("err", "w") if os.path.exists("err") else None -def debug(*args, **kwargs): +def debug(*args, **kwargs): # pragma: no cover if errf: print(*args, file=errf, **kwargs) errf.flush() diff --git a/src/wormhole/_send.py b/src/wormhole/_send.py index b039dbd..d0c45c0 100644 --- a/src/wormhole/_send.py +++ b/src/wormhole/_send.py @@ -12,7 +12,7 @@ class Send(object): _side = attrib(validator=instance_of(type(u""))) _timing = attrib(validator=provides(_interfaces.ITiming)) m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __attrs_post_init__(self): self._queue = [] diff --git a/src/wormhole/_terminator.py b/src/wormhole/_terminator.py index e6c65a0..2cb7327 100644 --- a/src/wormhole/_terminator.py +++ b/src/wormhole/_terminator.py @@ -6,7 +6,7 @@ from . import _interfaces @implementer(_interfaces.ITerminator) class Terminator(object): m = MethodicalMachine() - set_trace = getattr(m, "_setTrace", lambda self, f: None) + set_trace = getattr(m, "_setTrace", lambda self, f: None) # pragma: no cover def __init__(self): self._mood = None @@ -24,7 +24,7 @@ class Terminator(object): # TODO: rename o to 0, "" to 1. "S1" is special/terminal # so S0nm/S0n/S0m/S0, S1nm/S1n/S1m/(S1) - + # We start in Snmo (non-closing). When both nameplate and mailboxes are # done, and we're closing, then we stop the RendezvousConnector