def test_jieba_extract3(monkeypatch):
    """测试地名出现两次省名的情况"""
    monkeypatch.setattr(cpca, 'province_map', {'江苏': '江苏省', '上海市': '上海市'})
    monkeypatch.setattr(cpca, 'city_map', _dict2addr_map({'淮安': '淮安市'}))
    monkeypatch.setattr(cpca, 'area_map', _dict2addr_map({'清浦区': '清浦区'}))

    pca, addr = cpca._jieba_extract('我家的地址是江苏淮安清浦区人民路111号上海市')

    assert addr == '我家的地址是江苏淮安清浦区人民路111号上海市'
    assert pca.province == '江苏省'
    assert pca.province_pos == 6
    assert pca.city == '淮安市'
    assert pca.city_pos == 8
    assert pca.area == '清浦区'
    assert pca.area_pos == 10
def test_jieba_extract(monkeypatch):
    """地址全部在句子开头的情况"""
    monkeypatch.setattr(cpca, 'province_map', {'江苏': '江苏省'})
    monkeypatch.setattr(cpca, 'city_map', _dict2addr_map({'淮安': '淮安市'}))
    monkeypatch.setattr(cpca, 'area_map', _dict2addr_map({'清浦区': '清浦区'}))

    pca, addr = cpca._jieba_extract('江苏淮安清浦区人民路111号')

    assert addr == '人民路111号'
    assert pca.province == '江苏省'
    assert pca.province_pos == 0
    assert pca.city == '淮安市'
    assert pca.city_pos == 2
    assert pca.area == '清浦区'
    assert pca.area_pos == 4