Skip to content

Commit

Permalink
test: cover SopelMemoryWithDefault.__contains__()
Browse files Browse the repository at this point in the history
Since the whole point of this type is to have a thread-safe version of
`collections.defaultdict` and not have to check for `'key' in SMWD`
before accessing something, the `__contains__()` method (supporting the
`in` keyword) is never exercised in regular code.

The rest of `SopelMemoryWithDefault` is covered by other test cases for
code that *uses* the type, so I'll just keep this patch small.

Now the only uncovered code in `sopel/tools/memories.py` is for variadic
argument handling that we plan to remove anyway, so 98% is fine for now.
  • Loading branch information
dgw committed Nov 2, 2023
1 parent 3037752 commit 11ea3a8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/tools/test_tools_memories.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from sopel.tools import identifiers, memories


def test_sopel_default_memory_contains():
memory = memories.SopelMemoryWithDefault(list)
assert 'key' not in memory


def test_sopel_identifier_memory_none():
memory = memories.SopelIdentifierMemory()
assert None not in memory
Expand Down

0 comments on commit 11ea3a8

Please sign in to comment.