From e072e30ec49d6dc83789c80b480f6c3b4df4dd81 Mon Sep 17 00:00:00 2001 From: CrimsonGlory Date: Tue, 9 Oct 2018 17:55:47 +0000 Subject: [PATCH] Add test to avclass_labeler --- .gitignore | 3 ++- tests/test_avclass_labeler.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/test_avclass_labeler.py diff --git a/.gitignore b/.gitignore index ccdfdcf..07f8a98 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -lib/*.pyc +*.pyc +.cache/ diff --git a/tests/test_avclass_labeler.py b/tests/test_avclass_labeler.py new file mode 100644 index 0000000..a32a379 --- /dev/null +++ b/tests/test_avclass_labeler.py @@ -0,0 +1,22 @@ +import pytest +import subprocess +import os + + +def call_with_output(array): + p = subprocess.Popen(array, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + output, err = p.communicate() + return output, err + + +def avclass_labeler_bin(): + base_path = os.path.dirname(os.path.abspath(__file__)) + return os.path.join(base_path, '../avclass_labeler.py') + + +def test_avclass_labeler_subprocess(): + params = ['python', avclass_labeler_bin(), '-lb', 'data/malheurReference_lb.json', '-v', '-fam'] + output, err = call_with_output(params) + err = err.split('\n') + assert err[-4].find('[-] Samples: 3131 NoLabels:') != -1, "err=%s" % err