Modify super calls for python3

This commit is contained in:
Brandon Myers 2019-08-15 16:18:49 -05:00
Родитель 943507e819
Коммит 4d7f78e98f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 8AA79AD83045BBC7
10 изменённых файлов: 29 добавлений и 28 удалений

Просмотреть файл

@ -29,7 +29,7 @@ def mock_add_hostname_to_ip(ip):
class AlertTestSuite(UnitTestSuite):
def teardown(self):
os.chdir(self.orig_path)
super(AlertTestSuite, self).teardown()
super().teardown()
sys.path.remove(self.alerts_path)
sys.path.remove(self.alerts_lib_path)
if 'lib' in sys.modules:
@ -37,7 +37,7 @@ class AlertTestSuite(UnitTestSuite):
def setup(self):
self.orig_path = os.getcwd()
super(AlertTestSuite, self).setup()
super().setup()
self.alerts_path = os.path.join(os.path.dirname(__file__), "../../alerts")
self.alerts_lib_path = os.path.join(os.path.dirname(__file__), "../../alerts/lib")
sys.path.insert(0, self.alerts_path)

Просмотреть файл

@ -42,7 +42,7 @@ class TestHostnameFromIP(AlertTaskTest):
class TestAddHostnameToIP(AlertTaskTest):
def setup(self):
super(TestAddHostnameToIP, self).setup()
super().setup()
self.formatted_string = '{0} ({1})'
def test_internal_hostname(self):

Просмотреть файл

@ -7,7 +7,7 @@ class HTTPTestSuite(UnitTestSuite):
def setup(self):
self.app = TestApp(self.application)
super(HTTPTestSuite, self).setup()
super().setup()
def response_per_route(self, route):
return self.app.get(route)

Просмотреть файл

@ -16,4 +16,4 @@ class LoginputTestSuite(HTTPTestSuite):
OptionParser.parse_args = mock.Mock(return_value=(sample_config, {}))
from loginput import index as loginput_index
self.application = loginput_index.application
super(LoginputTestSuite, self).setup()
super().setup()

Просмотреть файл

@ -10,7 +10,7 @@ from tests.unit_test_suite import UnitTestSuite
class SearchQueryUnitTest(UnitTestSuite):
def setup(self):
super(SearchQueryUnitTest, self).setup()
super().setup()
self.query = SearchQuery()
assert self.query.must == []
assert self.query.must_not == []

Просмотреть файл

@ -8,7 +8,7 @@ from tests.unit_test_suite import UnitTestSuite
class BulkQueueTest(UnitTestSuite):
def setup(self):
super(BulkQueueTest, self).setup()
super().setup()
def num_objects_saved(self):
self.refresh(self.event_index_name)
@ -21,7 +21,7 @@ class BulkQueueTest(UnitTestSuite):
class TestBasicInit(BulkQueueTest):
def setup(self):
super(TestBasicInit, self).setup()
super().setup()
self.queue = BulkQueue(self.es_client)
def test_threshold(self):
@ -44,7 +44,7 @@ class TestInitWithThreshold(BulkQueueTest):
class TestAdd(BulkQueueTest):
def setup(self):
super(TestAdd, self).setup()
super().setup()
self.queue = BulkQueue(self.es_client, threshold=20)
def test_basic_add(self):

Просмотреть файл

@ -18,7 +18,7 @@ from tests.unit_test_suite import UnitTestSuite
class ElasticsearchClientTest(UnitTestSuite):
def setup(self):
super(ElasticsearchClientTest, self).setup()
super().setup()
self.es_client = ElasticsearchClient(self.options.esservers, bulk_refresh_time=3)
def get_num_events(self):
@ -50,7 +50,7 @@ class MockTransportClass:
class TestWriteWithRead(ElasticsearchClientTest):
def setup(self):
super(TestWriteWithRead, self).setup()
super().setup()
self.alert = {
'category': 'correlatedalerts',
@ -115,7 +115,7 @@ class TestNoResultsFound(ElasticsearchClientTest):
class TestCloseIndex(ElasticsearchClientTest):
def teardown(self):
super(TestCloseIndex, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('test_index')
@ -130,7 +130,7 @@ class TestCloseIndex(ElasticsearchClientTest):
class TestWritingToClosedIndex(ElasticsearchClientTest):
def teardown(self):
super(TestWritingToClosedIndex, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('test_index')
@ -147,7 +147,7 @@ class TestWritingToClosedIndex(ElasticsearchClientTest):
class TestOpenIndex(ElasticsearchClientTest):
def teardown(self):
super(TestOpenIndex, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('test_index')
@ -292,14 +292,14 @@ class TestSimpleWrites(ElasticsearchClientTest):
class BulkTest(ElasticsearchClientTest):
def setup(self):
super(BulkTest, self).setup()
super().setup()
self.mock_class = MockTransportClass()
self.mock_class.backup_function(self.es_client.es_connection.transport.perform_request)
self.es_client.es_connection.transport.perform_request = self.mock_class.perform_request
def teardown(self):
self.es_client.finish_bulk()
super(BulkTest, self).teardown()
super().teardown()
class TestBulkWrites(BulkTest):
@ -399,7 +399,7 @@ class TestWriteWithIDExists(ElasticsearchClientTest):
class TestGetIndices(ElasticsearchClientTest):
def teardown(self):
super(TestGetIndices, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('test_index')
@ -429,7 +429,7 @@ class TestGetIndices(ElasticsearchClientTest):
class TestIndexExists(ElasticsearchClientTest):
def teardown(self):
super(TestIndexExists, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('test_index')
@ -462,14 +462,14 @@ class TestClusterHealth(ElasticsearchClientTest):
class TestCreatingAlias(ElasticsearchClientTest):
def setup(self):
super(TestCreatingAlias, self).setup()
super().setup()
if self.config_delete_indexes:
self.es_client.delete_index('index1', True)
self.es_client.delete_index('index2', True)
self.es_client.delete_index('alias1', True)
def teardown(self):
super(TestCreatingAlias, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('index1', True)
self.es_client.delete_index('index2', True)
@ -512,7 +512,7 @@ class TestCreatingAlias(ElasticsearchClientTest):
class TestBulkInvalidFormatProblem(BulkTest):
def setup(self):
super(TestBulkInvalidFormatProblem, self).setup()
super().setup()
mapping = {
"mappings": {

Просмотреть файл

@ -19,9 +19,10 @@ import sys
class TestEsworkerSNSSQS(UnitTestSuite):
def teardown(self):
sys.path.remove(self.mq_path)
super().teardown()
def setup(self):
super(TestEsworkerSNSSQS, self).setup()
super().setup()
mq_conn = 'abc'
task_queue = 'example-logs-mozdef'
es_connection = self.es_client

Просмотреть файл

@ -30,4 +30,4 @@ class RestTestSuite(HTTPTestSuite):
importlib.reload(plugins)
from rest import index as rest_index
self.application = rest_index.application
super(RestTestSuite, self).setup()
super().setup()

Просмотреть файл

@ -46,12 +46,12 @@ class TestKibanaDashboardsRoute(RestTestSuite):
return self.es_client.save_object(body=dashboardjson, index='.kibana', doc_id=dashid)
def teardown(self):
super(TestKibanaDashboardsRoute, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('.kibana', True)
def setup(self):
super(TestKibanaDashboardsRoute, self).setup()
super().setup()
if self.config_delete_indexes:
self.es_client.delete_index('.kibana', True)
self.es_client.create_index('.kibana')
@ -84,14 +84,14 @@ class TestKibanaDashboardsRouteWithoutDashboards(RestTestSuite):
status_code = 200
def setup(self):
super(TestKibanaDashboardsRouteWithoutDashboards, self).setup()
super().setup()
if self.config_delete_indexes:
self.es_client.delete_index('.kibana', True)
self.es_client.create_index('.kibana')
time.sleep(0.2)
def teardown(self):
super(TestKibanaDashboardsRouteWithoutDashboards, self).teardown()
super().teardown()
if self.config_delete_indexes:
self.es_client.delete_index('.kibana', True)
@ -110,7 +110,7 @@ class TestLoginCountsRoute(RestTestSuite):
status_code = 200
def setup(self):
super(TestLoginCountsRoute, self).setup()
super().setup()
# ttesterson test events
for count in range(10):