aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-04-22 16:49:00 +0100
committerCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-04-22 16:50:38 +0100
commit906f4f52ab3e3daaf4bb893e69d0bcfee1f49726 (patch)
tree64382b7273fc330905b99ed6d552cde98297bf4f
parent7fa4586079ef2414129ab0a9a14d4fa33b6a6869 (diff)
downloadbrotli-906f4f52ab3e3daaf4bb893e69d0bcfee1f49726.zip
brotli-906f4f52ab3e3daaf4bb893e69d0bcfee1f49726.tar.gz
brotli-906f4f52ab3e3daaf4bb893e69d0bcfee1f49726.tar.bz2
[python] prepend build/lib folder to PYTHONPATH before running tests
-rw-r--r--.gitignore4
-rwxr-xr-xpython/tests/compatibility_test.py19
-rwxr-xr-xpython/tests/roundtrip_test.py24
3 files changed, 40 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index a9f411e..83973eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@
*.txt.uncompressed
*.bro
*.unbro
-/tools/bro
+tools/bro
+build/
+dist/
diff --git a/python/tests/compatibility_test.py b/python/tests/compatibility_test.py
index 81e305e..941b306 100755
--- a/python/tests/compatibility_test.py
+++ b/python/tests/compatibility_test.py
@@ -2,6 +2,7 @@
from __future__ import print_function
import sys
import os
+import sysconfig
from subprocess import check_call
import filecmp
@@ -14,6 +15,18 @@ def diff_q(first_file, second_file):
return 0
+# prepend ../../build/lib folder to PYTHONPATH
+LIB_DIRNAME = "lib.{platform}-{version[0]}.{version[1]}".format(
+ platform=sysconfig.get_platform(),
+ version=sys.version_info)
+BUILD_PATH = os.path.abspath(os.path.join("..", "..", "build", LIB_DIRNAME))
+TEST_ENV = os.environ.copy()
+if 'PYTHONPATH' not in TEST_ENV:
+ TEST_ENV['PYTHONPATH'] = BUILD_PATH
+else:
+ TEST_ENV['PYTHONPATH'] = BUILD_PATH + os.pathsep + TEST_ENV['PYTHONPATH']
+
+
PYTHON = sys.executable or "python"
BRO = os.path.abspath("../bro.py")
@@ -43,11 +56,13 @@ for filename in INPUTS.splitlines():
print('Testing decompression of file "%s"' % os.path.basename(filename))
uncompressed = os.path.splitext(filename)[0] + ".uncompressed"
expected = os.path.splitext(filename)[0]
- check_call([PYTHON, BRO, "-f", "-d", "-i", filename, "-o", uncompressed])
+ check_call([PYTHON, BRO, "-f", "-d", "-i", filename, "-o", uncompressed],
+ env=TEST_ENV)
if diff_q(uncompressed, expected) != 0:
sys.exit(1)
# Test the streaming version
with open(filename, "rb") as infile, open(uncompressed, "wb") as outfile:
- check_call([PYTHON, BRO, '-d'], stdin=infile, stdout=outfile)
+ check_call([PYTHON, BRO, '-d'], stdin=infile, stdout=outfile,
+ env=TEST_ENV)
if diff_q(uncompressed, expected) != 0:
sys.exit(1)
diff --git a/python/tests/roundtrip_test.py b/python/tests/roundtrip_test.py
index e9e8525..69391a6 100755
--- a/python/tests/roundtrip_test.py
+++ b/python/tests/roundtrip_test.py
@@ -2,6 +2,7 @@
from __future__ import print_function
import sys
import os
+import sysconfig
from subprocess import check_call, Popen, PIPE
import filecmp
@@ -14,6 +15,18 @@ def diff_q(first_file, second_file):
return 0
+# prepend ../../build/lib folder to PYTHONPATH
+LIB_DIRNAME = "lib.{platform}-{version[0]}.{version[1]}".format(
+ platform=sysconfig.get_platform(),
+ version=sys.version_info)
+BUILD_PATH = os.path.abspath(os.path.join("..", "..", "build", LIB_DIRNAME))
+TEST_ENV = os.environ.copy()
+if 'PYTHONPATH' not in TEST_ENV:
+ TEST_ENV['PYTHONPATH'] = BUILD_PATH
+else:
+ TEST_ENV['PYTHONPATH'] = BUILD_PATH + os.pathsep + TEST_ENV['PYTHONPATH']
+
+
PYTHON = sys.executable or "python"
BRO = os.path.abspath("../bro.py")
@@ -34,13 +47,16 @@ for filename in INPUTS.splitlines():
print('Roundtrip testing of file "%s"' % os.path.basename(filename))
compressed = os.path.splitext(filename)[0] + ".bro"
uncompressed = os.path.splitext(filename)[0] + ".unbro"
- check_call([PYTHON, BRO, "-f", "-i", filename, "-o", compressed])
- check_call([PYTHON, BRO, "-f", "-d", "-i", compressed, "-o", uncompressed])
+ check_call([PYTHON, BRO, "-f", "-i", filename, "-o", compressed],
+ env=TEST_ENV)
+ check_call([PYTHON, BRO, "-f", "-d", "-i", compressed, "-o", uncompressed],
+ env=TEST_ENV)
if diff_q(filename, uncompressed) != 0:
sys.exit(1)
# Test the streaming version
with open(filename, "rb") as infile, open(uncompressed, "wb") as outfile:
- p = Popen([PYTHON, BRO], stdin=infile, stdout=PIPE)
- check_call([PYTHON, BRO, "-d"], stdin=p.stdout, stdout=outfile)
+ p = Popen([PYTHON, BRO], stdin=infile, stdout=PIPE, env=TEST_ENV)
+ check_call([PYTHON, BRO, "-d"], stdin=p.stdout, stdout=outfile,
+ env=TEST_ENV)
if diff_q(filename, uncompressed) != 0:
sys.exit(1)