Commit f4fdc5a6 by William Tisäter

Make tests pass on Python 3.X

parent 671d3ab9
...@@ -62,9 +62,6 @@ class _GeoIPMetaclass(type): ...@@ -62,9 +62,6 @@ class _GeoIPMetaclass(type):
def __call__(cls, *args, **kwargs): def __call__(cls, *args, **kwargs):
""" Singleton method to gets an instance without reparsing """ Singleton method to gets an instance without reparsing
the database, the filename is being used as cache key. the database, the filename is being used as cache key.
@param cache: Used in tests for skipping instance caching
@type cache: bool
""" """
if len(args) > 0: if len(args) > 0:
filename = args[0] filename = args[0]
...@@ -74,7 +71,6 @@ class _GeoIPMetaclass(type): ...@@ -74,7 +71,6 @@ class _GeoIPMetaclass(type):
return None return None
if not kwargs.get('cache', True): if not kwargs.get('cache', True):
del kwargs['cache']
return super(_GeoIPMetaclass, cls).__call__(*args, **kwargs) return super(_GeoIPMetaclass, cls).__call__(*args, **kwargs)
cls._instance_lock.acquire() cls._instance_lock.acquire()
...@@ -88,7 +84,7 @@ class _GeoIPMetaclass(type): ...@@ -88,7 +84,7 @@ class _GeoIPMetaclass(type):
class GeoIP(object): class GeoIP(object):
__metaclass__ = _GeoIPMetaclass __metaclass__ = _GeoIPMetaclass
def __init__(self, filename, flags=0): def __init__(self, filename, flags=0, cache=True):
""" """
Initialize the class. Initialize the class.
...@@ -99,6 +95,8 @@ class GeoIP(object): ...@@ -99,6 +95,8 @@ class GeoIP(object):
MEMORY_CACHE (preload the whole file into memory) and MEMORY_CACHE (preload the whole file into memory) and
MMAP_CACHE (access the file via mmap). MMAP_CACHE (access the file via mmap).
@type flags: int @type flags: int
@param cache: Used in tests to skip instance caching
@type cache: bool
""" """
self._flags = flags self._flags = flags
......
...@@ -9,9 +9,6 @@ from tests.config import COUNTRY_DB_PATH ...@@ -9,9 +9,6 @@ from tests.config import COUNTRY_DB_PATH
class TestGenerals(unittest.TestCase): class TestGenerals(unittest.TestCase):
def testContructing(self): def testContructing(self):
gi = pygeoip.GeoIP()
self.assertEqual(gi, None)
gi = pygeoip.GeoIP(filename=COUNTRY_DB_PATH) gi = pygeoip.GeoIP(filename=COUNTRY_DB_PATH)
self.assertEqual(gi._type, 'STANDARD') self.assertEqual(gi._type, 'STANDARD')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment