File: test_unicode.py

package info (click to toggle)
pygeoip 0.3.2-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 240 kB
  • sloc: python: 1,835; makefile: 3
file content (18 lines) | stat: -rwxr-xr-x 587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- coding: utf-8 -*-
import unittest

import pygeoip
from pygeoip.const import PY2
from tests.config import CITY_DB_PATH


class TestGeoIPCacheMethods(unittest.TestCase):
    def setUp(self):
        self.de_hostname = 'www.osnabrueck.de'
        self.de_city = 'Osnabr\xfcck'.decode('latin1') if PY2 else 'Osnabrück'
        self.gic = pygeoip.GeoIP(CITY_DB_PATH)

    def testUnicodeCity(self):
        record = self.gic.record_by_name(self.de_hostname)
        self.assertEqual(type(record['city']), unicode if PY2 else str)
        self.assertEqual(record['city'], self.de_city)