summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2022-04-25 15:21:35 -0700
committerAdam Hupp <adam@hupp.org>2022-05-22 05:54:13 -0700
commit51e34d2b8b84f1a582b4dbbfa3693957ddc3f48a (patch)
treec15a36933be11d1b82685b0e787e55f95168770e
parent585373b5d952e579a9f7bd8f6418ca0bfd6a5e35 (diff)
downloadpython-magic-51e34d2b8b84f1a582b4dbbfa3693957ddc3f48a.tar.gz
use tox for all the multi-version testing
l---------.dockerignore1
-rw-r--r--.gitignore2
-rw-r--r--__init__.py0
-rwxr-xr-xtest/docker/alpine7
-rwxr-xr-xtest/docker/bionic11
-rw-r--r--test/docker/centos78
-rw-r--r--test/docker/centos88
-rwxr-xr-xtest/docker/focal11
-rwxr-xr-xtest/docker/xenial11
-rw-r--r--test/run_all_versions.py35
-rw-r--r--tox.ini7
11 files changed, 40 insertions, 61 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 120000
index 0000000..3e4e48b
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+.gitignore \ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 111565e..40c8c4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@ bin/
deb_dist
htmlcov/
lib/
-__pycache__/
+**/__pycache__
python_magic.egg-info
pip-selfcheck.json
pyvenv.cfg
diff --git a/__init__.py b/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/__init__.py
+++ /dev/null
diff --git a/test/docker/alpine b/test/docker/alpine
index eb511d7..c36b720 100755
--- a/test/docker/alpine
+++ b/test/docker/alpine
@@ -1,4 +1,7 @@
FROM python:3.8-alpine3.12
RUN apk add python3 python2 libmagic
-COPY . /python-magic
-CMD cd /python-magic/test && python3 ./run.py
+WORKDIR /python-magic
+COPY . .
+RUN python3 -m pip install tox
+CMD python3 -m tox
+
diff --git a/test/docker/bionic b/test/docker/bionic
index e335b8e..2fe482c 100755
--- a/test/docker/bionic
+++ b/test/docker/bionic
@@ -1,8 +1,9 @@
FROM ubuntu:bionic
+WORKDIR /python-magic
+COPY . .
RUN apt-get update
-RUN apt-get -y install python
-RUN apt-get -y install python3
-RUN apt-get -y install locales
+RUN apt-get -y install python python3 locales python3-pip libmagic1
RUN locale-gen en_US.UTF-8
-COPY . /python-magic
-CMD cd /python-magic/test && python3 ./run.py
+RUN python3 -m pip install tox
+CMD python3 -m tox
+
diff --git a/test/docker/centos7 b/test/docker/centos7
index f2ac6e4..10f170a 100644
--- a/test/docker/centos7
+++ b/test/docker/centos7
@@ -1,5 +1,9 @@
FROM centos:7
RUN yum -y update
RUN yum -y install file-devel python3 python2 which
-COPY . /python-magic
-CMD cd /python-magic/test && SKIP_FROM_DESCRIPTOR=1 python3 ./run.py
+WORKDIR /python-magic
+COPY . .
+RUN python3 -m pip install tox
+ENV SKIP_FROM_DESCRIPTOR=1
+CMD python3 -m tox
+
diff --git a/test/docker/centos8 b/test/docker/centos8
index 968f6b6..3b3da0a 100644
--- a/test/docker/centos8
+++ b/test/docker/centos8
@@ -4,6 +4,8 @@ RUN yum -y install file-libs python3 python2 which glibc-locale-source
RUN yum reinstall glibc-common -y && \
localedef -i en_US -f UTF-8 en_US.UTF-8 && \
echo "LANG=en_US.UTF-8" > /etc/locale.conf
-ENV LANG en_US.UTF-8
-COPY . /python-magic
-CMD cd /python-magic/test && python3 ./run.py
+WORKDIR /python-magic
+COPY . .
+RUN python3 -m pip install tox
+CMD python3 -m tox
+
diff --git a/test/docker/focal b/test/docker/focal
index 74e4d78..b35040b 100755
--- a/test/docker/focal
+++ b/test/docker/focal
@@ -1,8 +1,9 @@
FROM ubuntu:focal
+WORKDIR /python-magic
+COPY . .
RUN apt-get update
-RUN apt-get -y install python2
-RUN apt-get -y install python3
-RUN apt-get -y install locales
+RUN apt-get -y install python python3 locales python3-pip libmagic1
RUN locale-gen en_US.UTF-8
-COPY . /python-magic
-CMD cd /python-magic/test && python3 ./run.py
+RUN python3 -m pip install tox
+CMD python3 -m tox
+
diff --git a/test/docker/xenial b/test/docker/xenial
index bc0440b..e3c0433 100755
--- a/test/docker/xenial
+++ b/test/docker/xenial
@@ -1,8 +1,9 @@
FROM ubuntu:xenial
+WORKDIR /python-magic
+COPY . .
RUN apt-get update
-RUN apt-get -y install python
-RUN apt-get -y install python3
-RUN apt-get -y install locales
+RUN apt-get -y install python python3 locales python3-pip libmagic1
RUN locale-gen en_US.UTF-8
-COPY . /python-magic
-CMD cd /python-magic/test && python3 ./run.py
+RUN python3 -m pip install tox
+CMD python3 -m tox
+
diff --git a/test/run_all_versions.py b/test/run_all_versions.py
deleted file mode 100644
index d9e7ec5..0000000
--- a/test/run_all_versions.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import subprocess
-import os.path
-import sys
-
-this_dir = os.path.dirname(sys.argv[0])
-
-new_env = dict(os.environ)
-new_env.update({
- 'LC_ALL': 'en_US.UTF-8',
- 'PYTHONPATH': os.path.join(this_dir, ".."),
-})
-
-
-def has_py(version):
- ret = subprocess.run("which %s" % version, shell=True, stdout=subprocess.DEVNULL)
- return ret.returncode == 0
-
-
-def run_test(versions):
- found = False
- for i in versions:
- if not has_py(i):
- # if this version doesn't exist in path, skip
- continue
- found = True
- print("Testing %s" % i)
- subprocess.run([i, os.path.join(this_dir, "python_magic_test.py")], env=new_env, check=True)
- subprocess.run([i, os.path.join(this_dir, "libmagic_test.py")], env=new_env, check=True)
-
- if not found:
- sys.exit("No versions found: " + str(versions))
-
-run_test(["python2", "python2.7"])
-run_test(["python3.5", "python3.6", "python3.7", "python3.8", "python3.9"])
-
diff --git a/tox.ini b/tox.ini
index 6559598..1aa47a9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,15 +12,15 @@ envlist =
[testenv]
commands =
- coverage run --source=magic ./test/test.py
+ coverage run -m pytest
setenv =
COVERAGE_FILE=.coverage.{envname}
LC_ALL=en_US.UTF-8
deps =
.[test]
- zope.testrunner
coverage
+ pytest
[testenv:coverage-clean]
deps = coverage
@@ -44,4 +44,5 @@ commands =
deps = mypy
skip_install = true
commands =
- mypy magic.pyi
+ mypy -p magic
+