]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
tests: remove specific python2 and python3 tests
authorJason Ish <ish@unx.ca>
Thu, 7 Dec 2017 13:40:21 +0000 (07:40 -0600)
committerJason Ish <ish@unx.ca>
Thu, 7 Dec 2017 22:16:40 +0000 (16:16 -0600)
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.

tests/test_main.py

index a8b28e09060ec32ea7b58ca874fc18af1a96828f..1ed6ffb25b06d894e57b81fe9ad28f23db8c8f55 100644 (file)
@@ -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"),