Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-python-magic for
openSUSE:Factory checked in at 2022-10-12 18:23:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-python-magic (Old)
and /work/SRC/openSUSE:Factory/.python-python-magic.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-magic"
Wed Oct 12 18:23:30 2022 rev:8 rq:1009307 version:0.4.27
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-python-magic/python-python-magic.changes
2022-02-17 23:40:52.403700742 +0100
+++
/work/SRC/openSUSE:Factory/.python-python-magic.new.2275/python-python-magic.changes
2022-10-12 18:24:26.945628134 +0200
@@ -1,0 +2,8 @@
+Mon Oct 10 08:53:37 UTC 2022 - Dirk M??ller <[email protected]>
+
+- update to 0.4.27:
+ - remove spurious pyproject.toml that breaks source builds
+ - Use tox for all multi-version testing
+ - Fix use of pytest, use it via tox
+
+-------------------------------------------------------------------
Old:
----
0.4.25.tar.gz
New:
----
0.4.27.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-python-magic.spec ++++++
--- /var/tmp/diff_new_pack.PDFxjp/_old 2022-10-12 18:24:28.845632881 +0200
+++ /var/tmp/diff_new_pack.PDFxjp/_new 2022-10-12 18:24:28.849632891 +0200
@@ -19,13 +19,14 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define oldpython python
Name: python-python-magic
-Version: 0.4.25
+Version: 0.4.27
Release: 0
Summary: File type identification using libmagic
License: Python-2.0
Group: Development/Languages/Python
URL: https://github.com/ahupp/python-magic
Source: https://github.com/ahupp/python-magic/archive/%{version}.tar.gz
+BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module xml}
BuildRequires: fdupes
@@ -56,7 +57,7 @@
%check
export LC_ALL=en_US.UTF-8
-%pyunittest -v test.test
+%pytest
%files %{python_files}
%license LICENSE
++++++ 0.4.25.tar.gz -> 0.4.27.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/.dockerignore
new/python-magic-0.4.27/.dockerignore
--- old/python-magic-0.4.25/.dockerignore 1970-01-01 01:00:00.000000000
+0100
+++ new/python-magic-0.4.27/.dockerignore 2022-10-12 18:24:28.945633131
+0200
@@ -0,0 +1 @@
+symbolic link to .gitignore
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/.gitignore
new/python-magic-0.4.27/.gitignore
--- old/python-magic-0.4.25/.gitignore 2022-02-03 21:00:24.000000000 +0100
+++ new/python-magic-0.4.27/.gitignore 2022-06-07 21:50:57.000000000 +0200
@@ -4,7 +4,7 @@
deb_dist
htmlcov/
lib/
-__pycache__/
+**/__pycache__
python_magic.egg-info
pip-selfcheck.json
pyvenv.cfg
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/CHANGELOG
new/python-magic-0.4.27/CHANGELOG
--- old/python-magic-0.4.25/CHANGELOG 2022-02-03 21:00:24.000000000 +0100
+++ new/python-magic-0.4.27/CHANGELOG 2022-06-07 21:50:57.000000000 +0200
@@ -1,3 +1,10 @@
+Changes to 0.4.27:
+ - remove spurious pyproject.toml that breaks source builds
+
+Changes to 0.4.26:
+ - Use tox for all multi-version testing
+ - Fix use of pytest, use it via tox
+
Changes to 0.4.25:
- Support os.PathLike values in Magic.from_file and magic.from_file
- Handle some versions of libmagic that return mime string without charset
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/setup.py
new/python-magic-0.4.27/setup.py
--- old/python-magic-0.4.25/setup.py 2022-02-03 21:00:24.000000000 +0100
+++ new/python-magic-0.4.27/setup.py 2022-06-07 21:50:57.000000000 +0200
@@ -18,7 +18,7 @@
author='Adam Hupp',
author_email='[email protected]',
url="http://github.com/ahupp/python-magic",
- version='0.4.25',
+ version='0.4.27',
long_description=read('README.md'),
long_description_content_type='text/markdown',
packages=['magic'],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/README
new/python-magic-0.4.27/test/README
--- old/python-magic-0.4.25/test/README 2022-02-03 21:00:24.000000000 +0100
+++ new/python-magic-0.4.27/test/README 2022-06-07 21:50:57.000000000 +0200
@@ -1,10 +1,6 @@
-To run the tests across a selection of Ubuntu LTS versions:
+There are a few ways to run the python-magic tests
-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
+ 1. `pytest` will run the test suite against your default version of python
+ 2. `./test/run_all_versions.py` will run the tests against all installed
versions of python.
+ 3. `./test/run_all_docker_test.sh` will run against a variety of different
Linux distributions, using docker.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/docker/alpine
new/python-magic-0.4.27/test/docker/alpine
--- old/python-magic-0.4.25/test/docker/alpine 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test/docker/alpine 2022-06-07 21:50:57.000000000
+0200
@@ -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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/docker/bionic
new/python-magic-0.4.27/test/docker/bionic
--- old/python-magic-0.4.25/test/docker/bionic 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test/docker/bionic 2022-06-07 21:50:57.000000000
+0200
@@ -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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/docker/centos7
new/python-magic-0.4.27/test/docker/centos7
--- old/python-magic-0.4.25/test/docker/centos7 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test/docker/centos7 2022-06-07 21:50:57.000000000
+0200
@@ -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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/docker/centos8
new/python-magic-0.4.27/test/docker/centos8
--- old/python-magic-0.4.25/test/docker/centos8 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test/docker/centos8 2022-06-07 21:50:57.000000000
+0200
@@ -4,6 +4,8 @@
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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/docker/focal
new/python-magic-0.4.27/test/docker/focal
--- old/python-magic-0.4.25/test/docker/focal 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test/docker/focal 2022-06-07 21:50:57.000000000
+0200
@@ -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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/docker/xenial
new/python-magic-0.4.27/test/docker/xenial
--- old/python-magic-0.4.25/test/docker/xenial 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test/docker/xenial 2022-06-07 21:50:57.000000000
+0200
@@ -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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/libmagic_test.py
new/python-magic-0.4.27/test/libmagic_test.py
--- old/python-magic-0.4.25/test/libmagic_test.py 2022-02-03
21:00:24.000000000 +0100
+++ new/python-magic-0.4.27/test/libmagic_test.py 2022-06-07
21:50:57.000000000 +0200
@@ -3,12 +3,16 @@
import unittest
import os
import magic
+import os.path
# magic_descriptor is broken (?) in centos 7, so don't run those tests
SKIP_FROM_DESCRIPTOR = bool(os.environ.get('SKIP_FROM_DESCRIPTOR'))
+TESTDATA_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
'testdata'))
+
+
class MagicTestCase(unittest.TestCase):
- filename = 'testdata/test.pdf'
+ filename = os.path.join(TESTDATA_DIR, 'test.pdf')
expected_mime_type = 'application/pdf'
expected_encoding = 'us-ascii'
expected_name = ('PDF document, version 1.2', 'PDF document, version 1.2,
2 pages')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/python_magic_test.py
new/python-magic-0.4.27/test/python_magic_test.py
--- old/python-magic-0.4.25/test/python_magic_test.py 1970-01-01
01:00:00.000000000 +0100
+++ new/python-magic-0.4.27/test/python_magic_test.py 2022-06-07
21:50:57.000000000 +0200
@@ -0,0 +1,232 @@
+import os
+
+# for output which reports a local time
+os.environ['TZ'] = 'GMT'
+
+if os.environ.get('LC_ALL', '') != 'en_US.UTF-8':
+ # this ensure we're in a utf-8 default filesystem encoding which is
+ # necessary for some tests
+ raise Exception("must run `export LC_ALL=en_US.UTF-8` before running test
suite")
+
+import shutil
+import os.path
+import unittest
+
+import magic
+import sys
+
+# magic_descriptor is broken (?) in centos 7, so don't run those tests
+SKIP_FROM_DESCRIPTOR = bool(os.environ.get('SKIP_FROM_DESCRIPTOR'))
+
+class MagicTest(unittest.TestCase):
+ TESTDATA_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
'testdata'))
+
+ def test_version(self):
+ try:
+ self.assertTrue(magic.version() > 0)
+ except NotImplementedError:
+ pass
+
+ 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:
+ filename = os.path.join(self.TESTDATA_DIR, filename)
+ except TypeError:
+ filename = os.path.join(
+ self.TESTDATA_DIR.encode('utf-8'), filename)
+
+ if type(expected_value) is not tuple:
+ expected_value = (expected_value,)
+
+ with open(filename, 'rb') as f:
+ buf_value = m.from_buffer(f.read())
+
+ file_value = m.from_file(filename)
+
+ if buf_equals_file:
+ self.assertEqual(buf_value, file_value)
+
+ for value in (buf_value, file_value):
+ self.assertIn(value, expected_value)
+
+ def test_from_file_str_and_bytes(self):
+ filename = os.path.join(self.TESTDATA_DIR, "test.pdf")
+
+ self.assertEqual('application/pdf',
+ magic.from_file(filename, mime=True))
+ self.assertEqual('application/pdf',
+ magic.from_file(filename.encode('utf-8'), mime=True))
+
+ def test_from_descriptor_str_and_bytes(self):
+ if SKIP_FROM_DESCRIPTOR:
+ self.skipTest("magic_descriptor is broken in this version of
libmagic")
+
+ filename = os.path.join(self.TESTDATA_DIR, "test.pdf")
+ with open(filename) as f:
+ self.assertEqual('application/pdf',
+ magic.from_descriptor(f.fileno(), mime=True))
+ self.assertEqual('application/pdf',
+ magic.from_descriptor(f.fileno(), mime=True))
+
+ def test_from_buffer_str_and_bytes(self):
+ if SKIP_FROM_DESCRIPTOR:
+ self.skipTest("magic_descriptor is broken in this version of
libmagic")
+ m = magic.Magic(mime=True)
+
+ self.assertTrue(
+ m.from_buffer('#!/usr/bin/env python\nprint("foo")')
+ in ("text/x-python", "text/x-script.python"))
+ self.assertTrue(
+ m.from_buffer(b'#!/usr/bin/env python\nprint("foo")')
+ in ("text/x-python", "text/x-script.python"))
+
+ def test_mime_types(self):
+ dest = os.path.join(MagicTest.TESTDATA_DIR,
+ b'\xce\xbb'.decode('utf-8'))
+ shutil.copyfile(os.path.join(MagicTest.TESTDATA_DIR, 'lambda'), dest)
+ try:
+ m = magic.Magic(mime=True)
+ self.assert_values(m, {
+ 'magic._pyc_': ('application/octet-stream',
'text/x-bytecode.python', 'application/x-bytecode.python'),
+ 'test.pdf': 'application/pdf',
+ 'test.gz': ('application/gzip', 'application/x-gzip'),
+ 'test.snappy.parquet': 'application/octet-stream',
+ 'text.txt': 'text/plain',
+ b'\xce\xbb'.decode('utf-8'): 'text/plain',
+ b'\xce\xbb': 'text/plain',
+ })
+ finally:
+ os.unlink(dest)
+
+ def test_descriptions(self):
+ m = magic.Magic()
+ os.environ['TZ'] = 'UTC' # To get last modified date of test.gz in UTC
+ try:
+ self.assert_values(m, {
+ 'magic._pyc_': 'python 2.4 byte-compiled',
+ 'test.pdf': ('PDF document, version 1.2',
+ 'PDF document, version 1.2, 2 pages'),
+ 'test.gz':
+ ('gzip compressed data, was "test", from Unix, last '
+ 'modified: Sun Jun 29 01:32:52 2008',
+ 'gzip compressed data, was "test", last modified'
+ ': Sun Jun 29 01:32:52 2008, from Unix',
+ 'gzip compressed data, was "test", last modified'
+ ': Sun Jun 29 01:32:52 2008, from Unix, original size 15',
+ 'gzip compressed data, was "test", '
+ 'last modified: Sun Jun 29 01:32:52 2008, '
+ 'from Unix, original size modulo 2^32 15',
+ 'gzip compressed data, was "test", last modified'
+ ': Sun Jun 29 01:32:52 2008, from Unix, truncated'
+ ),
+ 'text.txt': 'ASCII text',
+ 'test.snappy.parquet': ('Apache Parquet', 'Par archive data'),
+ }, buf_equals_file=False)
+ finally:
+ del os.environ['TZ']
+
+ def test_extension(self):
+ try:
+ m = magic.Magic(extension=True)
+ self.assert_values(m, {
+ # some versions return '' for the extensions of a gz file,
+ # including w/ the command line. Who knows...
+ 'test.gz': ('gz/tgz/tpz/zabw/svgz', '', '???'),
+ 'name_use.jpg': 'jpeg/jpg/jpe/jfif',
+ })
+ except NotImplementedError:
+ self.skipTest('MAGIC_EXTENSION not supported in this version')
+
+ def test_unicode_result_nonraw(self):
+ m = magic.Magic(raw=False)
+ src = os.path.join(MagicTest.TESTDATA_DIR, 'pgpunicode')
+ result = m.from_file(src)
+ # NOTE: This check is added as otherwise some magic files don't
identify the test case as a PGP key.
+ if 'PGP' in result:
+ assert r"PGP\011Secret Sub-key -" == result
+ else:
+ raise unittest.SkipTest("Magic file doesn't return expected type.")
+
+ def test_unicode_result_raw(self):
+ m = magic.Magic(raw=True)
+ src = os.path.join(MagicTest.TESTDATA_DIR, 'pgpunicode')
+ result = m.from_file(src)
+ if 'PGP' in result:
+ assert b'PGP\tSecret Sub-key -' == result.encode('utf-8')
+ else:
+ raise unittest.SkipTest("Magic file doesn't return expected type.")
+
+ def test_mime_encodings(self):
+ m = magic.Magic(mime_encoding=True)
+ self.assert_values(m, {
+ 'text-iso8859-1.txt': 'iso-8859-1',
+ 'text.txt': 'us-ascii',
+ })
+
+ def test_errors(self):
+ m = magic.Magic()
+ self.assertRaises(IOError, m.from_file, 'nonexistent')
+ self.assertRaises(magic.MagicException, magic.Magic,
+ magic_file='nonexistent')
+ os.environ['MAGIC'] = 'nonexistent'
+ try:
+ self.assertRaises(magic.MagicException, magic.Magic)
+ finally:
+ del os.environ['MAGIC']
+
+ def test_keep_going(self):
+ filename = os.path.join(self.TESTDATA_DIR, 'keep-going.jpg')
+
+ m = magic.Magic(mime=True)
+ self.assertEqual(m.from_file(filename), 'image/jpeg')
+
+ try:
+ # this will throw if you have an "old" version of the library
+ # I'm otherwise not sure how to query if keep_going is supported
+ magic.version()
+ m = magic.Magic(mime=True, keep_going=True)
+ self.assertEqual(m.from_file(filename),
+ 'image/jpeg\\012- application/octet-stream')
+ except NotImplementedError:
+ pass
+
+ def test_rethrow(self):
+ old = magic.magic_buffer
+ try:
+ def t(x, y):
+ raise magic.MagicException("passthrough")
+
+ magic.magic_buffer = t
+
+ with self.assertRaises(magic.MagicException):
+ magic.from_buffer("hello", True)
+ finally:
+ magic.magic_buffer = old
+
+ def test_getparam(self):
+ m = magic.Magic(mime=True)
+ try:
+ m.setparam(magic.MAGIC_PARAM_INDIR_MAX, 1)
+ self.assertEqual(m.getparam(magic.MAGIC_PARAM_INDIR_MAX), 1)
+ except NotImplementedError:
+ pass
+
+ def test_name_count(self):
+ m = magic.Magic()
+ with open(os.path.join(self.TESTDATA_DIR, 'name_use.jpg'), 'rb') as f:
+ m.from_buffer(f.read())
+
+ def test_pathlike(self):
+ if sys.version_info < (3, 6):
+ return
+ from pathlib import Path
+ path = Path(self.TESTDATA_DIR, "test.pdf")
+ m = magic.Magic(mime=True)
+ self.assertEqual('application/pdf', m.from_file(path))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/run.py
new/python-magic-0.4.27/test/run.py
--- old/python-magic-0.4.25/test/run.py 2022-02-03 21:00:24.000000000 +0100
+++ new/python-magic-0.4.27/test/run.py 1970-01-01 01:00:00.000000000 +0100
@@ -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, "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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/run_all_docker_test.sh
new/python-magic-0.4.27/test/run_all_docker_test.sh
--- old/python-magic-0.4.25/test/run_all_docker_test.sh 1970-01-01
01:00:00.000000000 +0100
+++ new/python-magic-0.4.27/test/run_all_docker_test.sh 2022-06-07
21:50:57.000000000 +0200
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+set -x
+
+ROOT=$(dirname $0)/..
+cd $ROOT
+
+for f in test/docker/*; do
+ H=$(docker build -q -f ${f} .)
+ docker run --rm $H
+done
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test/test.py
new/python-magic-0.4.27/test/test.py
--- old/python-magic-0.4.25/test/test.py 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test/test.py 1970-01-01 01:00:00.000000000
+0100
@@ -1,232 +0,0 @@
-import os
-
-# for output which reports a local time
-os.environ['TZ'] = 'GMT'
-
-if os.environ.get('LC_ALL', '') != 'en_US.UTF-8':
- # this ensure we're in a utf-8 default filesystem encoding which is
- # necessary for some tests
- raise Exception("must run `export LC_ALL=en_US.UTF-8` before running test
suite")
-
-import shutil
-import os.path
-import unittest
-
-import magic
-import sys
-
-# magic_descriptor is broken (?) in centos 7, so don't run those tests
-SKIP_FROM_DESCRIPTOR = bool(os.environ.get('SKIP_FROM_DESCRIPTOR'))
-
-class MagicTest(unittest.TestCase):
- TESTDATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'testdata')
-
- def test_version(self):
- try:
- self.assertTrue(magic.version() > 0)
- except NotImplementedError:
- pass
-
- 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:
- filename = os.path.join(self.TESTDATA_DIR, filename)
- except TypeError:
- filename = os.path.join(
- self.TESTDATA_DIR.encode('utf-8'), filename)
-
- if type(expected_value) is not tuple:
- expected_value = (expected_value,)
-
- with open(filename, 'rb') as f:
- buf_value = m.from_buffer(f.read())
-
- file_value = m.from_file(filename)
-
- if buf_equals_file:
- self.assertEqual(buf_value, file_value)
-
- for value in (buf_value, file_value):
- self.assertIn(value, expected_value)
-
- def test_from_file_str_and_bytes(self):
- filename = os.path.join(self.TESTDATA_DIR, "test.pdf")
-
- self.assertEqual('application/pdf',
- magic.from_file(filename, mime=True))
- self.assertEqual('application/pdf',
- magic.from_file(filename.encode('utf-8'), mime=True))
-
- def test_from_descriptor_str_and_bytes(self):
- if SKIP_FROM_DESCRIPTOR:
- self.skipTest("magic_descriptor is broken in this version of
libmagic")
-
- filename = os.path.join(self.TESTDATA_DIR, "test.pdf")
- with open(filename) as f:
- self.assertEqual('application/pdf',
- magic.from_descriptor(f.fileno(), mime=True))
- self.assertEqual('application/pdf',
- magic.from_descriptor(f.fileno(), mime=True))
-
- def test_from_buffer_str_and_bytes(self):
- if SKIP_FROM_DESCRIPTOR:
- self.skipTest("magic_descriptor is broken in this version of
libmagic")
- m = magic.Magic(mime=True)
-
- self.assertTrue(
- m.from_buffer('#!/usr/bin/env python\nprint("foo")')
- in ("text/x-python", "text/x-script.python"))
- self.assertTrue(
- m.from_buffer(b'#!/usr/bin/env python\nprint("foo")')
- in ("text/x-python", "text/x-script.python"))
-
- def test_mime_types(self):
- dest = os.path.join(MagicTest.TESTDATA_DIR,
- b'\xce\xbb'.decode('utf-8'))
- shutil.copyfile(os.path.join(MagicTest.TESTDATA_DIR, 'lambda'), dest)
- try:
- m = magic.Magic(mime=True)
- self.assert_values(m, {
- 'magic._pyc_': ('application/octet-stream',
'text/x-bytecode.python', 'application/x-bytecode.python'),
- 'test.pdf': 'application/pdf',
- 'test.gz': ('application/gzip', 'application/x-gzip'),
- 'test.snappy.parquet': 'application/octet-stream',
- 'text.txt': 'text/plain',
- b'\xce\xbb'.decode('utf-8'): 'text/plain',
- b'\xce\xbb': 'text/plain',
- })
- finally:
- os.unlink(dest)
-
- def test_descriptions(self):
- m = magic.Magic()
- os.environ['TZ'] = 'UTC' # To get last modified date of test.gz in UTC
- try:
- self.assert_values(m, {
- 'magic._pyc_': 'python 2.4 byte-compiled',
- 'test.pdf': ('PDF document, version 1.2',
- 'PDF document, version 1.2, 2 pages'),
- 'test.gz':
- ('gzip compressed data, was "test", from Unix, last '
- 'modified: Sun Jun 29 01:32:52 2008',
- 'gzip compressed data, was "test", last modified'
- ': Sun Jun 29 01:32:52 2008, from Unix',
- 'gzip compressed data, was "test", last modified'
- ': Sun Jun 29 01:32:52 2008, from Unix, original size 15',
- 'gzip compressed data, was "test", '
- 'last modified: Sun Jun 29 01:32:52 2008, '
- 'from Unix, original size modulo 2^32 15',
- 'gzip compressed data, was "test", last modified'
- ': Sun Jun 29 01:32:52 2008, from Unix, truncated'
- ),
- 'text.txt': 'ASCII text',
- 'test.snappy.parquet': ('Apache Parquet', 'Par archive data'),
- }, buf_equals_file=False)
- finally:
- del os.environ['TZ']
-
- def test_extension(self):
- try:
- m = magic.Magic(extension=True)
- self.assert_values(m, {
- # some versions return '' for the extensions of a gz file,
- # including w/ the command line. Who knows...
- 'test.gz': ('gz/tgz/tpz/zabw/svgz', '', '???'),
- 'name_use.jpg': 'jpeg/jpg/jpe/jfif',
- })
- except NotImplementedError:
- self.skipTest('MAGIC_EXTENSION not supported in this version')
-
- def test_unicode_result_nonraw(self):
- m = magic.Magic(raw=False)
- src = os.path.join(MagicTest.TESTDATA_DIR, 'pgpunicode')
- result = m.from_file(src)
- # NOTE: This check is added as otherwise some magic files don't
identify the test case as a PGP key.
- if 'PGP' in result:
- assert r"PGP\011Secret Sub-key -" == result
- else:
- raise unittest.SkipTest("Magic file doesn't return expected type.")
-
- def test_unicode_result_raw(self):
- m = magic.Magic(raw=True)
- src = os.path.join(MagicTest.TESTDATA_DIR, 'pgpunicode')
- result = m.from_file(src)
- if 'PGP' in result:
- assert b'PGP\tSecret Sub-key -' == result.encode('utf-8')
- else:
- raise unittest.SkipTest("Magic file doesn't return expected type.")
-
- def test_mime_encodings(self):
- m = magic.Magic(mime_encoding=True)
- self.assert_values(m, {
- 'text-iso8859-1.txt': 'iso-8859-1',
- 'text.txt': 'us-ascii',
- })
-
- def test_errors(self):
- m = magic.Magic()
- self.assertRaises(IOError, m.from_file, 'nonexistent')
- self.assertRaises(magic.MagicException, magic.Magic,
- magic_file='nonexistent')
- os.environ['MAGIC'] = 'nonexistent'
- try:
- self.assertRaises(magic.MagicException, magic.Magic)
- finally:
- del os.environ['MAGIC']
-
- def test_keep_going(self):
- filename = os.path.join(self.TESTDATA_DIR, 'keep-going.jpg')
-
- m = magic.Magic(mime=True)
- self.assertEqual(m.from_file(filename), 'image/jpeg')
-
- try:
- # this will throw if you have an "old" version of the library
- # I'm otherwise not sure how to query if keep_going is supported
- magic.version()
- m = magic.Magic(mime=True, keep_going=True)
- self.assertEqual(m.from_file(filename),
- 'image/jpeg\\012- application/octet-stream')
- except NotImplementedError:
- pass
-
- def test_rethrow(self):
- old = magic.magic_buffer
- try:
- def t(x, y):
- raise magic.MagicException("passthrough")
-
- magic.magic_buffer = t
-
- with self.assertRaises(magic.MagicException):
- magic.from_buffer("hello", True)
- finally:
- magic.magic_buffer = old
-
- def test_getparam(self):
- m = magic.Magic(mime=True)
- try:
- m.setparam(magic.MAGIC_PARAM_INDIR_MAX, 1)
- self.assertEqual(m.getparam(magic.MAGIC_PARAM_INDIR_MAX), 1)
- except NotImplementedError:
- pass
-
- def test_name_count(self):
- m = magic.Magic()
- with open(os.path.join(self.TESTDATA_DIR, 'name_use.jpg'), 'rb') as f:
- m.from_buffer(f.read())
-
- def test_pathlike(self):
- if sys.version_info < (3, 6):
- return
- from pathlib import Path
- path = Path(self.TESTDATA_DIR, "test.pdf")
- m = magic.Magic(mime=True)
- self.assertEqual('application/pdf', m.from_file(path))
-
-
-if __name__ == '__main__':
- unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/test_docker.sh
new/python-magic-0.4.27/test_docker.sh
--- old/python-magic-0.4.25/test_docker.sh 2022-02-03 21:00:24.000000000
+0100
+++ new/python-magic-0.4.27/test_docker.sh 1970-01-01 01:00:00.000000000
+0100
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-# Test with various versions of ubuntu. This more or less re-creates the
-# Travis CI test environment
-
-set -e
-
-DEFAULT_TARGETS="xenial bionic focal centos7 centos8 archlinux alpine"
-
-TARGETS=${1:-${DEFAULT_TARGETS}}
-
-HERE=`dirname $0`
-
-for i in $TARGETS; do
- TAG="python_magic/${i}:latest"
- docker build -t $TAG -f ${HERE}/test/docker/$i .
- docker run $TAG
-done
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-magic-0.4.25/tox.ini
new/python-magic-0.4.27/tox.ini
--- old/python-magic-0.4.25/tox.ini 2022-02-03 21:00:24.000000000 +0100
+++ new/python-magic-0.4.27/tox.ini 2022-06-07 21:50:57.000000000 +0200
@@ -12,15 +12,15 @@
[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 @@
deps = mypy
skip_install = true
commands =
- mypy magic.pyi
+ mypy -p magic
+