summaryrefslogtreecommitdiff
path: root/tests/test_utilities.py
blob: 4f802f4057fbb38f7270ca1c349329962c2b4774 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pickle

from blinker._utilities import symbol


def test_symbols():
    foo = symbol('foo')
    assert foo.name == 'foo'
    assert foo is symbol('foo')

    bar = symbol('bar')
    assert foo is not bar
    assert foo != bar
    assert not foo == bar

    assert repr(foo) == 'foo'


def test_pickled_symbols():
    foo = symbol('foo')

    for protocol in 0, 1, 2:
        roundtrip = pickle.loads(pickle.dumps(foo))
        assert roundtrip is foo