def testFilter(self):        
        try:
            import GeoIP
        except ImportError:
            print >> sys.stderr, "GeoIP Python package not available - skipping geoip unittest."
            return        
        
        # Check positive filter
        self.options['filter'] = 'United States'
        output = [(geocode, ip, line) for geocode, ip, line in geoip(fh=self.fh, **self.options)]
        self.assertEquals(len(output), 2, "Output size was different than expected: %s" % str(len(output)))
        
        # Check negative filter
        self.options['filter'] = 'India'
        output = [(geocode, ip, line) for geocode, ip, line in geoip(fh=self.fh, **self.options)]
        self.assertEquals(len(output), 0, "Output size was different than expected: %s" % str(len(output)))
Test GeoIP filtering functionality
dataset/ETHPy150Open adamhadani/logtools/logtools/test/test_logtools.py/GeoIPTestCase.testFilter