Skip to content

Commit

Permalink
use Event._split to build slot
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzsnz committed Aug 27, 2024
1 parent 210f48d commit 05ee827
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/slots_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test Slot and Slots"""

import types
import weakref

import pytest
Expand Down Expand Up @@ -41,14 +42,14 @@ def error_func():
def slots_fixture():
"""Slots fixture"""
obj = Obj()
meth = obj.method
_obj, meth = Event._split(obj.method)
obj2 = Obj()
wr = weakref.ref(obj2)
slots = Slots()
slots.add(meth, None, None)
slots.add(_obj, None, meth)
slots.add(None, None, func)
slots.add(None, wr, None)
yield slots, meth, wr, obj
yield slots, obj.method, wr, obj


class TestSlot:
Expand Down Expand Up @@ -118,16 +119,18 @@ def test_slots_exists(self, slots_fixture):

slots, meth, wr, _ = slots_fixture
#
assert slots.exists(meth, None)
_obj, _meth = Event._split(meth)
assert slots.exists(_obj, _meth)
assert slots.exists(wr(), None)
assert slots.exists(None, func)

def test_slots_remove_obj(self, slots_fixture):
"""Test Slots.remove_obj"""
slots, meth, wr, _ = slots_fixture
#
slots.remove_obj(meth)
assert not slots.exists(meth, None)
_obj, _meth = Event._split(meth)
slots.remove_obj(_obj)
assert not slots.exists(_obj, _meth)
assert slots.exists(wr(), None)
#
slots.remove_obj(wr)
Expand All @@ -140,9 +143,10 @@ def test_slots_remove_ref(self, slots_fixture):
slots, meth, wr, _ = slots_fixture

#
_obj, _meth = Event._split(meth)
slots.remove_ref(wr)
assert not slots.exists(wr, None)
assert slots.exists(meth, None)
assert slots.exists(_obj, _meth)
assert slots.exists(None, func)

def test_slots_remove(self, slots_fixture):
Expand Down

0 comments on commit 05ee827

Please sign in to comment.