|
a |
|
b/tests/test_base.py |
|
|
1 |
import pytest |
|
|
2 |
from deidentify.base import Annotation |
|
|
3 |
|
|
|
4 |
|
|
|
5 |
def test_annotation(): |
|
|
6 |
ann_a = Annotation(text='test', start=12, end=15, tag='ABC', doc_id='123', ann_id='456') |
|
|
7 |
ann_b = Annotation(text='test', start=12, end=15, tag='ABC', doc_id='123', ann_id='456') |
|
|
8 |
ann_c = Annotation(text='test2', start=12, end=15, tag='ABC', doc_id='123', ann_id='456') |
|
|
9 |
|
|
|
10 |
assert ann_a == ann_b |
|
|
11 |
assert ann_a != ann_c |
|
|
12 |
|
|
|
13 |
with pytest.raises(AttributeError): |
|
|
14 |
ann_a.text = "Annotation should be immutable" |
|
|
15 |
|
|
|
16 |
# Annotation should also be hashable |
|
|
17 |
assert len(set([ann_a, ann_b, ann_c])) == 2 |