Skip to content

Commit

Permalink
fix(test): urrlib from python 2 to 3
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Fontana <[email protected]>
  • Loading branch information
fntlnz authored and poiana committed Mar 23, 2020
1 parent fbcdb57 commit a9658d4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/falco_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import stat
import subprocess
import sys
import urllib
import urllib.request

from avocado import Test
from avocado import main
Expand Down Expand Up @@ -141,7 +141,7 @@ def setUp(self):
else:
detect_counts = {}
for item in self.detect_counts:
for key, value in item.items():
for key, value in list(item.items()):
detect_counts[key] = value
self.detect_counts = detect_counts

Expand Down Expand Up @@ -184,7 +184,7 @@ def setUp(self):
else:
outputs = []
for item in self.outputs:
for key, value in item.items():
for key, value in list(item.items()):
output = {}
output['file'] = key
output['line'] = value
Expand Down Expand Up @@ -238,7 +238,7 @@ def check_rules_events(self, res):
self.log.debug("Expected events for rules: {}".format(self.rules_events))
self.log.debug("Actual events for rules: {}".format(found_events))

for rule in found_events.keys():
for rule in list(found_events.keys()):
if found_events.get(rule) != self.rules_events.get(rule):
self.fail("rule {}: expected events {} differs from actual events {}".format(rule, self.rules_events.get(rule), found_events.get(rule)))

Expand Down Expand Up @@ -277,7 +277,7 @@ def check_detections_by_rule(self, res):

triggered_rules = match.group(1)

for rule, count in self.detect_counts.items():
for rule, count in list(self.detect_counts.items()):
expected = '\s{}: (\d+)'.format(re.sub(r'([$\.*+?()[\]{}|^])', r'\\\1', rule))
match = re.search(expected, triggered_rules)

Expand Down Expand Up @@ -440,7 +440,7 @@ def test(self):
if not os.path.isfile(self.psp_conv_path):
self.log.info("Downloading {} to {}".format(self.psp_conv_url, self.psp_conv_path))

urllib.urlretrieve(self.psp_conv_url, self.psp_conv_path)
urllib.request.urlretrieve(self.psp_conv_url, self.psp_conv_path)
os.chmod(self.psp_conv_path, stat.S_IEXEC)

conv_cmd = '{} convert psp --psp-path {} --rules-path {}'.format(
Expand Down

0 comments on commit a9658d4

Please sign in to comment.