Skip to content
Permalink
Browse files

Merge pull request #1419 from mozilla/remove_syspath_loginputrest

Remove sys.path from http test suites
  • Loading branch information...
pwnbus committed Aug 8, 2019
2 parents 25027c6 + 8267816 commit 73f3ef356295578b39d5defe6215c8049eae0520
Showing with 15 additions and 17 deletions.
  1. +1 −1 tests/http_test_suite.py
  2. +3 −5 tests/loginput/loginput_test_suite.py
  3. +11 −11 tests/rest/rest_test_suite.py
@@ -1,6 +1,6 @@
from webtest import TestApp

from unit_test_suite import UnitTestSuite
from tests.unit_test_suite import UnitTestSuite


class HTTPTestSuite(UnitTestSuite):
@@ -1,13 +1,11 @@
import sys
import os

from mozdef_util.utilities.dot_dict import DotDict

import mock
from configlib import OptionParser

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
from http_test_suite import HTTPTestSuite
from tests.http_test_suite import HTTPTestSuite


class LoginputTestSuite(HTTPTestSuite):
@@ -16,6 +14,6 @@ def setup(self):
sample_config = DotDict()
sample_config.configfile = os.path.join(os.path.dirname(__file__), 'index.conf')
OptionParser.parse_args = mock.Mock(return_value=(sample_config, {}))
from loginput import index
self.application = index.application
from loginput import index as loginput_index
self.application = loginput_index.application
super(LoginputTestSuite, self).setup()
@@ -1,14 +1,12 @@
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))
from http_test_suite import HTTPTestSuite
import sys
import mock
import importlib
from configlib import OptionParser

from mozdef_util.utilities.dot_dict import DotDict

import mock
from configlib import OptionParser
import importlib
from tests.http_test_suite import HTTPTestSuite


class RestTestDict(DotDict):
@@ -18,16 +16,18 @@ def __dict__(self):


class RestTestSuite(HTTPTestSuite):
def teardown(self):
sys.path.remove(self.rest_path)

def setup(self):
sample_config = RestTestDict()
sample_config.configfile = os.path.join(os.path.dirname(__file__), 'index.conf')
OptionParser.parse_args = mock.Mock(return_value=(sample_config, {}))

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../rest"))
self.rest_path = os.path.join(os.path.dirname(__file__), "../../rest")
sys.path.insert(0, self.rest_path)
import plugins
importlib.reload(plugins)
from rest import index

self.application = index.application
from rest import index as rest_index
self.application = rest_index.application
super(RestTestSuite, self).setup()

0 comments on commit 73f3ef3

Please sign in to comment.
You can’t perform that action at this time.