From: Jason Ish Date: Thu, 7 Dec 2017 13:40:21 +0000 (-0600) Subject: tests: remove specific python2 and python3 tests X-Git-Tag: 1.0.0b1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54f9dd0d0bde558468ed3230a815d2135d842d4c;p=thirdparty%2Fsuricata-update.git tests: remove specific python2 and python3 tests With tox, the tests are run under multiple versions of Python. Just use the interpreter running the tests to hit all versions instead of relying whats installed on the host system. --- diff --git a/tests/test_main.py b/tests/test_main.py index a8b28e0..1ed6ffb 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -17,6 +17,7 @@ from __future__ import print_function +import sys import os import unittest import shlex @@ -71,8 +72,7 @@ class TestRulecat(unittest.TestCase): "tests/emerging-current_events.rules") self.assertIsNone(files) - @unittest.skipIf(not has_python2(), "python2 not available") - def test_run_python2(self): + def test_run(self): old_path = os.getcwd() try: os.chdir(os.path.dirname(os.path.realpath(__file__))) @@ -80,8 +80,10 @@ class TestRulecat(unittest.TestCase): shutil.rmtree("tmp") os.makedirs("./tmp/rules") subprocess.check_call( - ["/usr/bin/env", "python2", + ["/usr/bin/env", sys.executable, "../bin/suricata-update", + "-D", "./tmp", + "-v", "-c", "./update.yaml", "--url", "file://%s/emerging.rules.tar.gz" % ( @@ -97,50 +99,6 @@ class TestRulecat(unittest.TestCase): ], env={ "PATH": os.getenv("PATH"), - "SOURCE_DIRECTORY": "/tmp", - }, - stdout=open("./tmp/stdout", "wb"), - stderr=open("./tmp/stderr", "wb"), - ) - shutil.rmtree("tmp") - except: - if os.path.exists("./tmp/stdout"): - print("STDOUT") - print(open("./tmp/stdout").read()) - if os.path.exists("./tmp/stderr"): - print("STDERR") - print(open("./tmp/stderr").read()) - raise - finally: - os.chdir(old_path) - - @unittest.skipIf(not has_python3(), "python3 not available") - def test_run_python3(self): - old_path = os.getcwd() - try: - os.chdir(os.path.dirname(os.path.realpath(__file__))) - if os.path.exists("./tmp"): - shutil.rmtree("tmp") - os.makedirs("./tmp/rules") - subprocess.check_call( - ["/usr/bin/env", "python2", - "../bin/suricata-update", - "-c", "./update.yaml", - "--url", - "file://%s/emerging.rules.tar.gz" % ( - os.getcwd()), - "--local", "./rule-with-unicode.rules", - "--force", - "--output", "./tmp/rules/", - "--yaml-fragment", "./tmp/suricata-rules.yaml", - "--sid-msg-map", "./tmp/sid-msg.map", - "--sid-msg-map-2", "./tmp/sid-msg-v2.map", - "--no-test", - "--reload-command", "true", - ], - env={ - "PATH": os.getenv("PATH"), - "SOURCE_DIRECTORY": "/tmp", }, stdout=open("./tmp/stdout", "wb"), stderr=open("./tmp/stderr", "wb"),