fix: Python2 support.

Fix #274
pull/277/head
Raphaël Vinot 2018-09-17 13:59:25 -07:00
parent 50a5a86ca6
commit ceedb6e95c
2 changed files with 14 additions and 15 deletions

View File

@ -26,8 +26,7 @@ setup(
'Topic :: Security', 'Topic :: Security',
'Topic :: Internet', 'Topic :: Internet',
], ],
test_suite="tests.test_offline", install_requires=['six', 'requests', 'python-dateutil', 'jsonschema', 'setuptools>=36.4', 'python-dateutil', 'enum;python_version<"3.4"'],
install_requires=['six', 'requests', 'python-dateutil', 'jsonschema', 'setuptools>=36.4', 'python-dateutil'],
extras_require={'fileobjects': ['lief>=0.8', 'python-magic'], extras_require={'fileobjects': ['lief>=0.8', 'python-magic'],
'neo': ['py2neo'], 'neo': ['py2neo'],
'openioc': ['beautifulsoup4'], 'openioc': ['beautifulsoup4'],
@ -39,6 +38,7 @@ setup(
'requests-mock', 'requests-mock',
'six' 'six'
], ],
test_suite="tests.test_offline",
include_package_data=True, include_package_data=True,
package_data={'pymisp': ['data/*.json', package_data={'pymisp': ['data/*.json',
'data/misp-objects/schema_objects.json', 'data/misp-objects/schema_objects.json',

View File

@ -204,7 +204,6 @@ class TestOffline(unittest.TestCase):
self.assertEqual(key[0]["type"], "regkey|value") self.assertEqual(key[0]["type"], "regkey|value")
self.assertIn("foobar|foobar", key[0]["value"]) self.assertIn("foobar|foobar", key[0]["value"])
def test_addAttributes(self, m): def test_addAttributes(self, m):
self.initURI(m) self.initURI(m)
p = MockPyMISP(self.domain, self.key) p = MockPyMISP(self.domain, self.key)
@ -364,7 +363,7 @@ class TestOffline(unittest.TestCase):
def test_flatten_error_messages_singular(self, m): def test_flatten_error_messages_singular(self, m):
self.initURI(m) self.initURI(m)
pymisp = PyMISP(self.domain, self.key) pymisp = PyMISP(self.domain, self.key)
error = pymisp.get(1) pymisp.get(1)
response = self.auth_error_msg response = self.auth_error_msg
response['error'] = ['foo', 'bar', 'baz'] response['error'] = ['foo', 'bar', 'baz']
messages = pymisp.flatten_error_messages(response) messages = pymisp.flatten_error_messages(response)
@ -405,7 +404,7 @@ class TestOffline(unittest.TestCase):
self.initURI(m) self.initURI(m)
pymisp = PyMISP(self.domain, self.key) pymisp = PyMISP(self.domain, self.key)
try: try:
_ = pymisp.change_toids(self.key, 42) pymisp.change_toids(self.key, 42)
self.assertFalse('Exception required for off domain value') self.assertFalse('Exception required for off domain value')
except Exception: except Exception:
pass pass
@ -434,7 +433,7 @@ class TestOffline(unittest.TestCase):
self.initURI(m) self.initURI(m)
pymisp = PyMISP(self.domain, self.key) pymisp = PyMISP(self.domain, self.key)
try: try:
_ = pymisp.freetext(1, None, adhereToWarninglists='hard') pymisp.freetext(1, None, adhereToWarninglists='hard')
self.assertFalse('Exception required for off domain value') self.assertFalse('Exception required for off domain value')
except Exception: except Exception:
pass pass
@ -452,9 +451,9 @@ class TestOffline(unittest.TestCase):
def test_sample_upload(self, m): def test_sample_upload(self, m):
self.initURI(m) self.initURI(m)
pymisp = PyMISP(self.domain, self.key) pymisp = PyMISP(self.domain, self.key)
upload = pymisp.upload_sample("tmux", "tests/viper-test-files/test_files/tmux", 1) pymisp.upload_sample("tmux", "tests/viper-test-files/test_files/tmux", 1)
upload = pymisp.upload_sample("tmux", "non_existing_file", 1) pymisp.upload_sample("tmux", "non_existing_file", 1)
upload = pymisp.upload_sample("tmux", b"binblob", 1) pymisp.upload_sample("tmux", b"binblob", 1)
def test_get_all_tags(self, m): def test_get_all_tags(self, m):
self.initURI(m) self.initURI(m)