summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2020-01-11 23:31:03 -0800
committerAdam Hupp <adam@hupp.org>2020-01-11 23:46:38 -0800
commit0cc14ee1dcd7e53efc74cb2e00df89e630b3d0c5 (patch)
treebbbab0bcd3140f635e59277ec6dd6a1e37473ad3
parent18c909c4c98463d8292a7d1733aec007f178f1e5 (diff)
downloadpython-magic-0cc14ee1dcd7e53efc74cb2e00df89e630b3d0c5.tar.gz
Add dockerfiles for running tests on various Ubuntu LTS versions
-rwxr-xr-xtest/Dockerfile_bionic8
-rwxr-xr-xtest/Dockerfile_focal8
-rwxr-xr-xtest/Dockerfile_xenial8
-rw-r--r--test/README10
-rwxr-xr-xtest/run.sh2
-rwxr-xr-xtest/test.py5
6 files changed, 39 insertions, 2 deletions
diff --git a/test/Dockerfile_bionic b/test/Dockerfile_bionic
new file mode 100755
index 0000000..c180ea9
--- /dev/null
+++ b/test/Dockerfile_bionic
@@ -0,0 +1,8 @@
+FROM ubuntu:bionic
+RUN apt-get update
+RUN apt-get -y install python
+RUN apt-get -y install python3
+RUN apt-get -y install locales
+RUN locale-gen en_US.UTF-8
+COPY . /python-magic
+CMD cd /python-magic/test && ./run.sh
diff --git a/test/Dockerfile_focal b/test/Dockerfile_focal
new file mode 100755
index 0000000..c9e4049
--- /dev/null
+++ b/test/Dockerfile_focal
@@ -0,0 +1,8 @@
+FROM ubuntu:focal
+RUN apt-get update
+RUN apt-get -y install python
+RUN apt-get -y install python3
+RUN apt-get -y install locales
+RUN locale-gen en_US.UTF-8
+COPY . /python-magic
+CMD cd /python-magic/test && ./run.sh
diff --git a/test/Dockerfile_xenial b/test/Dockerfile_xenial
new file mode 100755
index 0000000..1d43070
--- /dev/null
+++ b/test/Dockerfile_xenial
@@ -0,0 +1,8 @@
+FROM ubuntu:xenial
+RUN apt-get update
+RUN apt-get -y install python
+RUN apt-get -y install python3
+RUN apt-get -y install locales
+RUN locale-gen en_US.UTF-8
+COPY . /python-magic
+CMD cd /python-magic/test && ./run.sh
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..12d4e4f
--- /dev/null
+++ b/test/README
@@ -0,0 +1,10 @@
+To run the tests across a selection of Ubuntu LTS versions:
+
+docker build -t "python_magic/xenial:latest" -f test/Dockerfile_xenial .
+docker build -t "python_magic/bionic:latest" -f test/Dockerfile_bionic .
+docker build -t "python_magic/focal:latest" -f test/Dockerfile_focal .
+
+docker run python_magic/xenial:latest
+docker run python_magic/bionic:latest
+docker run python_magic/focal:latest
+
diff --git a/test/run.sh b/test/run.sh
index 106a1e4..04c77b9 100755
--- a/test/run.sh
+++ b/test/run.sh
@@ -6,7 +6,7 @@ export LC_ALL=en_US.UTF-8
THISDIR=`dirname $0`
export PYTHONPATH=${THISDIR}/..
-PYTHONS="python2.7 python3.5 python3.7"
+PYTHONS="python2.7 python3.5 python3.6 python3.7"
for pyver in $PYTHONS; do
if which $pyver > /dev/null; then
diff --git a/test/test.py b/test/test.py
index c15227d..c6ba522 100755
--- a/test/test.py
+++ b/test/test.py
@@ -6,11 +6,14 @@ import os.path
import unittest
import magic
-
+import sys
class MagicTest(unittest.TestCase):
TESTDATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdata')
+ def test_fs_encoding(self):
+ self.assertEqual('utf-8', sys.getfilesystemencoding().lower())
+
def assert_values(self, m, expected_values, buf_equals_file=True):
for filename, expected_value in expected_values.items():
try: