Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use StringIO.StringIO() with python2 #36

Merged
merged 2 commits into from
Apr 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions contrib/tests/suite.py → contrib/tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
import sys
import json
import unittest
from io import StringIO
from io import open

from io import open
from cortexutils.analyzer import Analyzer

# Different lib when using python3 or 2
if sys.version_info >= (3, 0):
from io import StringIO
else:
from StringIO import StringIO


def load_test_fixture(fixture_path):
path = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -19,6 +24,7 @@ def load_test_fixture(fixture_path):
sys.stdin = StringIO(input)
sys.stdout = StringIO()


class TestMinimalConfig(unittest.TestCase):

def setUp(self):
Expand All @@ -41,6 +47,7 @@ def test_params_data(self):
self.assertEqual(self.analyzer.getParam('data'), "1.1.1.1")
self.assertEqual(self.analyzer.get_param('data'), "1.1.1.1")


class TestProxyConfig(unittest.TestCase):

def setUp(self):
Expand All @@ -56,6 +63,7 @@ def test_proxy_config(self):
self.assertEqual(os.environ['http_proxy'], proxy_url)
self.assertEqual(os.environ['https_proxy'], proxy_url)


class TestTlpConfig(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -87,6 +95,7 @@ def test_check_tlp_ok(self):
# __check_tlp
self.assertEqual(self.analyzer._Analyzer__check_tlp(), True)


class TestErrorResponse(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -116,6 +125,7 @@ def test_error_response(self):
self.assertEqual(json_output['input']['config']['apikey'], 'REMOVED')
self.assertEqual(json_output['input']['config']['api_key'], 'REMOVED')


class TestReportResponse(unittest.TestCase):

def setUp(self):
Expand Down