diff --git a/lib/woothee/__init__.py b/lib/woothee/__init__.py index 600e7b9..eb4a6bc 100644 --- a/lib/woothee/__init__.py +++ b/lib/woothee/__init__.py @@ -28,14 +28,14 @@ def parse(useragent): def is_crawler(useragent): - return len(useragent) > 0 and useragent != '-'\ + return useragent is not None and len(useragent) > 0 and useragent != '-'\ and try_crawler(useragent, {}) def exec_parse(useragent): result = {} - if len(useragent) < 1 or useragent == '-': + if useragent is None or len(useragent) < 1 or useragent == '-': return result if try_crawler(useragent, result): diff --git a/tests/test.py b/tests/test.py index 4d3022c..a7eba44 100644 --- a/tests/test.py +++ b/tests/test.py @@ -6,12 +6,10 @@ import os import sys import unittest +import yaml BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(BASE_PATH, 'lib')) - -import yaml - TESTSET_DIR = os.path.join(BASE_PATH, 'woothee', 'testsets') TARGETS = [ @@ -31,6 +29,7 @@ ['pc_lowpriority.yaml', 'PC/LowPriority'], ['misc.yaml', 'Misc'], ['crawler_nonmajor.yaml', 'Crawler/NonMajor'], + ['blank.yaml', 'Blank'], ] @@ -101,16 +100,6 @@ def test_non_provide_testsets(self): import woothee - # 33 line lib/woothee/__init__.py - self.assertEqual({ - "name": "UNKNOWN", - "version": "UNKNOWN", - "os": "UNKNOWN", - "os_version": "UNKNOWN", - "category": "UNKNOWN", - "vendor": "UNKNOWN", - }, woothee.parse("")) - # 48 line in lib/woothee/appliance.py self.assertEqual({ "name": "Nintendo DSi", @@ -268,6 +257,7 @@ def _callFUT(self, *args, **kwargs): def test_false(self): self.assertFalse(self._callFUT("")) self.assertFalse(self._callFUT("-")) + self.assertFalse(self._callFUT(None)) self.assertFalse(self._callFUT( "Mozilla/5.0 (Windows NT 6.3; " "Trident/7.0; rv:11.0) like Gecko" diff --git a/woothee b/woothee index 61766c8..a03d10a 160000 --- a/woothee +++ b/woothee @@ -1 +1 @@ -Subproject commit 61766c87f52a1fd866509b06a55b93186b5c4921 +Subproject commit a03d10a77d5aaea9b8e5a0a3ba5accaa71720d78