__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
import pytest
from netaddr.core import Publisher, Subscriber
import pprint
class Subject(Publisher):
pass
class Observer(Subscriber):
def __init__(self, id):
self.id = id
def update(self, data):
return repr(self), pprint.pformat(data)
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.id)
def test_pubsub():
s = Subject()
s.attach(Observer('foo'))
s.attach(Observer('bar'))
data = [
{'foo': 42},
{'list': [1, '2', list(range(10))]},
{'strings': ['foo', 'bar', 'baz', 'quux']},
]
s.notify(data)
s.notify(['foo', 'bar', 'baz'])
with pytest.raises(TypeError):
s.attach('foo')
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 0 B | 0644 |
|
| test_pubsub.py | File | 707 B | 0644 |
|