def test_none_on_collection_event(self):
        class Foo(object):
            pass
        class Bar(object):
            pass
        instrumentation.register_class(Foo)
        instrumentation.register_class(Bar)
        attributes.register_attribute(Foo, 'barlist', uselist=True,
                useobject=True)
        canary = []
        def append(state, child, initiator):
            canary.append((state, child))
        def remove(state, child, initiator):
            canary.append((state, child))
        event.listen(Foo.barlist, 'append', append)
        event.listen(Foo.barlist, 'remove', remove)

        b1, b2 = Bar(), Bar()
        f1 = Foo()
        f1.barlist.append(None)
        eq_(canary, [(f1, None)])

        canary[:] = []
        f1 = Foo()
        f1.barlist = [None, b2]
        eq_(canary, [(f1, None), (f1, b2)])

        canary[:] = []
        f1 = Foo()
        f1.barlist = [b1, None, b2]
        eq_(canary, [(f1, b1), (f1, None), (f1, b2)])

        f1.barlist.remove(None)
        eq_(canary, [(f1, b1), (f1, None), (f1, b2), (f1, None)])
test that append/remove of None in collections emits events.
dataset/ETHPy150Open zzzeek/sqlalchemy/test/orm/test_attributes.py/ListenerTest.test_none_on_collection_event