Python: Update bro_test to reference script directly (#582)

This commit is contained in:
Alex Nicksay 2017-08-08 04:25:39 -04:00 committed by Eugene Kliuchnikov
parent 3917011ddb
commit 019091f994
3 changed files with 9 additions and 11 deletions

View File

@ -13,9 +13,9 @@ project_dir = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
src_dir = os.path.join(project_dir, 'python')
test_dir = os.path.join(project_dir, 'tests')
PYTHON = sys.executable or 'python'
BRO = os.path.join(src_dir, 'bro.py')
python_exe = sys.executable or 'python'
bro_path = os.path.join(src_dir, 'bro.py')
BRO_ARGS = [python_exe, bro_path]
# Get the platform/version-specific build folder.
# By default, the distutils build base is in the same location as setup.py.

View File

@ -9,8 +9,7 @@ import unittest
from . import _test_utils
import brotli
PYTHON = _test_utils.PYTHON
BRO = _test_utils.BRO
BRO_ARGS = _test_utils.BRO_ARGS
TEST_ENV = _test_utils.TEST_ENV
@ -28,13 +27,12 @@ class TestBroDecompress(_test_utils.TestCase):
def _decompress_file(self, test_data):
temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
args = [PYTHON, BRO, '-f', '-d', '-i', test_data, '-o',
temp_uncompressed]
args = BRO_ARGS + ['-f', '-d', '-i', test_data, '-o', temp_uncompressed]
subprocess.check_call(args, env=TEST_ENV)
def _decompress_pipe(self, test_data):
temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
args = [PYTHON, BRO, '-d']
args = BRO_ARGS + ['-d']
with open(temp_uncompressed, 'wb') as out_file:
with open(test_data, 'rb') as in_file:
subprocess.check_call(
@ -61,14 +59,14 @@ class TestBroCompress(_test_utils.TestCase):
temp_uncompressed = _test_utils.get_temp_uncompressed_name(test_data)
temp_compressed = _test_utils.get_temp_compressed_name(test_data)
original = test_data
args = [PYTHON, BRO, '-f', '-d']
args = BRO_ARGS + ['-f', '-d']
args.extend(['-i', temp_compressed, '-o', temp_uncompressed])
subprocess.check_call(args, env=TEST_ENV)
self.assertFilesMatch(temp_uncompressed, original)
def _compress_file(self, test_data, **kwargs):
temp_compressed = _test_utils.get_temp_compressed_name(test_data)
args = [PYTHON, BRO, '-f']
args = BRO_ARGS + ['-f']
if 'quality' in kwargs:
args.extend(['-q', str(kwargs['quality'])])
if 'lgwin' in kwargs:
@ -78,7 +76,7 @@ class TestBroCompress(_test_utils.TestCase):
def _compress_pipe(self, test_data, **kwargs):
temp_compressed = _test_utils.get_temp_compressed_name(test_data)
args = [PYTHON, BRO]
args = BRO_ARGS
if 'quality' in kwargs:
args.extend(['-q', str(kwargs['quality'])])
if 'lgwin' in kwargs:

0
python/tests/decompressor_test.py Executable file → Normal file
View File