diff --git a/tools/coveragerc b/tools/coveragerc index b47d57aee0..24b0536d71 100644 --- a/tools/coveragerc +++ b/tools/coveragerc @@ -15,6 +15,8 @@ exclude_lines = raise UnexpectedWebhookEventType # Don't require coverage for blocks only run when type-checking if TYPE_CHECKING: + # Don't require coverage for abstract methods; they're never called. + @abstractmethod # Don't require coverage for the settings.LOG_API_EVENT_TYPES code paths # These are only run in a special testing mode, so will fail normal coverage. if settings.LOG_API_EVENT_TYPES: diff --git a/tools/test-backend b/tools/test-backend index 83a1fb73a9..e3ce1c4dae 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -93,7 +93,6 @@ not_yet_fully_covered = {path for target in [ 'zerver/lib/parallel.py', 'zerver/lib/profile.py', 'zerver/lib/queue.py', - 'zerver/lib/rate_limiter.py', 'zerver/lib/sqlalchemy_utils.py', 'zerver/lib/storage.py', 'zerver/lib/stream_recipient.py', diff --git a/zerver/lib/rate_limiter.py b/zerver/lib/rate_limiter.py index b6b8cbfd3e..06da8519bb 100644 --- a/zerver/lib/rate_limiter.py +++ b/zerver/lib/rate_limiter.py @@ -369,7 +369,7 @@ class RedisRateLimiterBackend(RateLimiterBackend): if key_blocked is not None: # We are manually blocked. Report for how much longer we will be - if blocking_ttl_b is None: + if blocking_ttl_b is None: # nocoverage # defensive code, this should never happen blocking_ttl = 0.5 else: blocking_ttl = int(blocking_ttl_b) @@ -436,7 +436,7 @@ class RedisRateLimiterBackend(RateLimiterBackend): # If no exception was raised in the execution, there were no transaction conflicts break - except redis.WatchError: + except redis.WatchError: # nocoverage # Ideally we'd have a test for this. if count > 10: raise RateLimiterLockingException() count += 1 diff --git a/zerver/tests/test_rate_limiter.py b/zerver/tests/test_rate_limiter.py index 91b59b75dc..1617c923fd 100644 --- a/zerver/tests/test_rate_limiter.py +++ b/zerver/tests/test_rate_limiter.py @@ -83,7 +83,7 @@ class RateLimiterBackendBase(ZulipTestCase): """ This depends on the algorithm used in the backend, and should be defined by the test class. """ - raise NotImplementedError # nocoverage + raise NotImplementedError() def test_hit_ratelimits(self) -> None: obj = self.create_object('test', [(2, 3), ])