Hello community,

here is the log from the commit of package python-python-magic for 
openSUSE:Factory checked in at 2018-08-22 14:20:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-python-magic (Old)
 and      /work/SRC/openSUSE:Factory/.python-python-magic.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-python-magic"

Wed Aug 22 14:20:49 2018 rev:2 rq:630745 version:0.4.15

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-python-magic/python-python-magic.changes  
2017-09-14 21:16:20.505065297 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-python-magic.new/python-python-magic.changes 
    2018-08-22 14:20:53.754428823 +0200
@@ -1,0 +2,14 @@
+Tue Aug 21 10:31:23 UTC 2018 - [email protected]
+
+- Version update to 0.4.15:
+  * Few test tweaks
+- Enable tests
+- Add patch to fix gzip detection in tests:
+  * magic-tests.patch
+- Add patch to fix working with new file:
+  * magic-new-file.patch
+- Add patch to work with new mimedb:
+  * magic-new-mime.patch
+- Add patch magic-pep8.patch to have other patches apply cleanly
+
+-------------------------------------------------------------------

Old:
----
  python-magic-0.4.13.tar.gz

New:
----
  0.4.15.tar.gz
  magic-new-file.patch
  magic-new-mime.patch
  magic-pep8.patch
  magic-tests.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-python-magic.spec ++++++
--- /var/tmp/diff_new_pack.VXe85Z/_old  2018-08-22 14:20:54.118429684 +0200
+++ /var/tmp/diff_new_pack.VXe85Z/_new  2018-08-22 14:20:54.118429684 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-python-magic
 #
-# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,34 +17,32 @@
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%bcond_with     test
 %define         oldpython python
 Name:           python-python-magic
-Version:        0.4.13
+Version:        0.4.15
 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://files.pythonhosted.org/packages/source/p/python-magic/python-magic-%{version}.tar.gz
-BuildRequires:  %{python_module devel}
+URL:            https://github.com/ahupp/python-magic
+Source:         https://github.com/ahupp/python-magic/archive/%{version}.tar.gz
+Patch0:         magic-new-mime.patch
+Patch1:         magic-pep8.patch
+Patch2:         magic-tests.patch
+Patch3:         magic-new-file.patch
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  fdupes
-BuildRequires:  python-rpm-macros
 BuildRequires:  file
+BuildRequires:  python-rpm-macros
 Requires:       file
 # python-python-magic and python-magic use the same namespace (ie. filename)
 # and have a very similar functionality but are incompatible to each other.
-# Upstream discussions:
 # https://github.com/ahupp/python-magic/issues/21
-# https://github.com/ahupp/python-magic/issues/33
-# https://github.com/ahupp/python-magic/issues/57
 Conflicts:      python-magic
+BuildArch:      noarch
 %ifpython2
 Conflicts:      %{oldpython}-magic
 %endif
-BuildArch:      noarch
-
 %python_subpackages
 
 %description
@@ -54,6 +52,7 @@
 
 %prep
 %setup -q -n python-magic-%{version}
+%autopatch -p1
 
 %build
 %python_build
@@ -62,18 +61,12 @@
 %python_install
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
-%if %{with test}
 %check
-pushd test
-export PYTHONPATH='..'
 export LANG=en_US.UTF-8
-%python_exec test.py
-popd
-%endif
+%python_exec setup.py test
 
 %files %{python_files}
-%defattr(-,root,root,-)
-%doc LICENSE
+%license LICENSE
 %{python_sitelib}/magic.py*
 %pycache_only %{python_sitelib}/__pycache__/magic*.py*
 %{python_sitelib}/python_magic-%{version}-py*.egg-info

++++++ python-magic-0.4.13.tar.gz -> 0.4.15.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/.gitignore 
new/python-magic-0.4.15/.gitignore
--- old/python-magic-0.4.13/.gitignore  1970-01-01 01:00:00.000000000 +0100
+++ new/python-magic-0.4.15/.gitignore  2017-12-04 07:06:41.000000000 +0100
@@ -0,0 +1,2 @@
+deb_dist
+python_magic.egg-info
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/.travis.yml 
new/python-magic-0.4.15/.travis.yml
--- old/python-magic-0.4.13/.travis.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/python-magic-0.4.15/.travis.yml 2017-12-04 07:06:41.000000000 +0100
@@ -0,0 +1,26 @@
+language: python
+
+# needed to use trusty
+sudo: required
+
+dist: xenial
+
+python:
+  - "2.6"
+  - "2.7"
+  - "3.3"
+  - "3.4"
+  - "3.5"
+  - "3.6"
+  - "nightly"
+
+install:
+  - pip install coverage
+  - python setup.py install
+
+script:
+  - coverage run setup.py test
+
+after_success:
+  - pip install coveralls && coveralls
+  - pip install codecov && codecov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/MANIFEST.in 
new/python-magic-0.4.15/MANIFEST.in
--- old/python-magic-0.4.13/MANIFEST.in 2017-03-20 07:23:14.000000000 +0100
+++ new/python-magic-0.4.15/MANIFEST.in 2017-12-04 07:06:41.000000000 +0100
@@ -1,4 +1,2 @@
 include *.py
 include LICENSE
-include test/testdata/*
-include test/*.sh
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/PKG-INFO 
new/python-magic-0.4.15/PKG-INFO
--- old/python-magic-0.4.13/PKG-INFO    2017-03-20 07:30:47.000000000 +0100
+++ new/python-magic-0.4.15/PKG-INFO    1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-Metadata-Version: 1.1
-Name: python-magic
-Version: 0.4.13
-Summary: File type identification using libmagic
-Home-page: http://github.com/ahupp/python-magic
-Author: Adam Hupp
-Author-email: [email protected]
-License: MIT
-Description: This module uses ctypes to access the libmagic file type
-        identification library.  It makes use of the local magic database and
-        supports both textual and MIME-type output.
-        
-Keywords: mime magic file
-Platform: UNKNOWN
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/README.md 
new/python-magic-0.4.15/README.md
--- old/python-magic-0.4.13/README.md   1970-01-01 01:00:00.000000000 +0100
+++ new/python-magic-0.4.15/README.md   2017-12-04 07:06:41.000000000 +0100
@@ -0,0 +1,120 @@
+# python-magic
+[![PyPI 
version](https://badge.fury.io/py/python-magic.svg)](https://badge.fury.io/py/python-magic)
+[![Build 
Status](https://travis-ci.org/ahupp/python-magic.svg?branch=master)](https://travis-ci.org/ahupp/python-magic)
+
+python-magic is a python interface to the libmagic file type
+identification library.  libmagic identifies file types by checking
+their headers according to a predefined list of file types. This
+functionality is exposed to the command line by the Unix command
+`file`.
+
+## Usage
+
+```python
+>>> import magic
+>>> magic.from_file("testdata/test.pdf")
+'PDF document, version 1.2'
+>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
+'PDF document, version 1.2'
+>>> magic.from_file("testdata/test.pdf", mime=True)
+'application/pdf'
+```
+
+There is also a `Magic` class that provides more direct control,
+including overriding the magic database file and turning on character
+encoding detection.  This is not recommended for general use.  In
+particular, it's not safe for sharing across multiple threads and
+will fail throw if this is attempted.
+
+```python
+>>> f = magic.Magic(uncompress=True)
+>>> f.from_file('testdata/test.gz')
+'ASCII text (gzip compressed data, was "test", last modified: Sat Jun 28
+21:32:52 2008, from Unix)'
+```
+
+You can also combine the flag options:
+
+```python
+>>> f = magic.Magic(mime=True, uncompress=True)
+>>> f.from_file('testdata/test.gz')
+'text/plain'
+```
+
+## Versioning
+
+Minor version bumps should be backwards compatible.  Major bumps are not.
+
+## Name Conflict
+
+There are, sadly, two libraries which use the module name `magic`.  Both have 
been around for quite a while.If you are using this module and get an error 
using a method like `open`, your code is expecting the other one.  Hopefully 
one day these will be reconciled.
+
+## Installation
+
+The current stable version of python-magic is available on pypi and
+can be installed by running `pip install python-magic`.
+
+Other sources:
+
+- pypi: http://pypi.python.org/pypi/python-magic/
+- github: https://github.com/ahupp/python-magic
+
+### Windows
+
+You'll need DLLs for libmagic.  @julian-r has uploaded a versoin of this 
project that includes binaries to pypi:
+https://pypi.python.org/pypi/python-magic-bin/0.4.14
+
+Other sources of the libraries in the past have been [File for 
Windows](http://gnuwin32.sourceforge.net/packages/file.htm) .  You will need to 
copy the file `magic` out of `[binary-zip]\share\misc`, and pass it's location 
to `Magic(magic_file=...)`.  
+
+If you are using a 64-bit build of python, you'll need 64-bit libmagic 
binaries which can be found here: https://github.com/pidydx/libmagicwin64. 
Newer version can be found here: https://github.com/nscaife/file-windows.
+
+
+
+### OSX
+
+- When using Homebrew: `brew install libmagic`
+- When using macports: `port install file`
+
+### Troubleshooting
+
+- 'MagicException: could not find any magic files!': some
+  installations of libmagic do not correctly point to their magic
+  database file.  Try specifying the path to the file explicitly in the
+  constructor: `magic.Magic(magic_file="path_to_magic_file")`.
+
+- 'WindowsError: [Error 193] %1 is not a valid Win32 application':
+  Attempting to run the 32-bit libmagic DLL in a 64-bit build of
+  python will fail with this error.  Here are 64-bit builds of libmagic for 
windows: https://github.com/pidydx/libmagicwin64
+
+- 'WindowsError: exception: access violation writing 0x00000000 ' This may 
indicate you are mixing 
+  Windows Python and Cygwin Python. Make sure your libmagic and python builds 
are consistent.
+
+## Author
+
+Written by Adam Hupp in 2001 for a project that never got off the
+ground.  It originally used SWIG for the C library bindings, but
+switched to ctypes once that was part of the python standard library.
+
+You can contact me via my [website](http://hupp.org/adam) or
+[github](http://github.com/ahupp).
+
+## Contributors
+
+Thanks to these folks on github who submitted features and bugfixes.
+
+-   Amit Sethi
+-   [bigben87](https://github.com/bigben87)
+-   [fallgesetz](https://github.com/fallgesetz)
+-   [FlaPer87](https://github.com/FlaPer87)
+-   [lukenowak](https://github.com/lukenowak)
+-   NicolasDelaby
+-   [email protected]
+-   SimpleSeb
+-   [tehmaze](https://github.com/tehmaze)
+
+## License
+
+python-magic is distributed under the MIT license.  See the included
+LICENSE file for details.
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/magic.py 
new/python-magic-0.4.15/magic.py
--- old/python-magic-0.4.13/magic.py    2017-03-20 07:22:59.000000000 +0100
+++ new/python-magic-0.4.15/magic.py    2017-12-04 07:06:41.000000000 +0100
@@ -72,6 +72,11 @@
         """
         with self.lock:
             try:
+                # if we're on python3, convert buf to bytes
+                # otherwise this string is passed as wchar*
+                # which is not what libmagic expects
+                if type(buf) == str and str != bytes:
+                   buf = buf.encode('utf-8', errors='replace')
                 return maybe_decode(magic_buffer(self.cookie, buf))
             except MagicException as e:
                 return self._handle509Bug(e)
@@ -213,7 +218,7 @@
                   (sys.version_info[0] >= 3 and
                    isinstance(filename, str))
     if is_unicode:
-        return filename.encode('utf-8')
+        return filename.encode('utf-8', 'surrogateescape')
     else:
         return filename
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/python_magic.egg-info/PKG-INFO 
new/python-magic-0.4.15/python_magic.egg-info/PKG-INFO
--- old/python-magic-0.4.13/python_magic.egg-info/PKG-INFO      2017-03-20 
07:30:47.000000000 +0100
+++ new/python-magic-0.4.15/python_magic.egg-info/PKG-INFO      1970-01-01 
01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-Metadata-Version: 1.1
-Name: python-magic
-Version: 0.4.13
-Summary: File type identification using libmagic
-Home-page: http://github.com/ahupp/python-magic
-Author: Adam Hupp
-Author-email: [email protected]
-License: MIT
-Description: This module uses ctypes to access the libmagic file type
-        identification library.  It makes use of the local magic database and
-        supports both textual and MIME-type output.
-        
-Keywords: mime magic file
-Platform: UNKNOWN
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/python-magic-0.4.13/python_magic.egg-info/SOURCES.txt 
new/python-magic-0.4.15/python_magic.egg-info/SOURCES.txt
--- old/python-magic-0.4.13/python_magic.egg-info/SOURCES.txt   2017-03-20 
07:30:47.000000000 +0100
+++ new/python-magic-0.4.15/python_magic.egg-info/SOURCES.txt   1970-01-01 
01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-LICENSE
-MANIFEST.in
-__init__.py
-magic.py
-setup.cfg
-setup.py
-python_magic.egg-info/PKG-INFO
-python_magic.egg-info/SOURCES.txt
-python_magic.egg-info/dependency_links.txt
-python_magic.egg-info/top_level.txt
-test/run.sh
-test/test.py
-test/testdata/keep-going.jpg
-test/testdata/lambda
-test/testdata/magic.pyc
-test/testdata/test.gz
-test/testdata/test.pdf
-test/testdata/text-iso8859-1.txt
-test/testdata/text.txt
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/python-magic-0.4.13/python_magic.egg-info/dependency_links.txt 
new/python-magic-0.4.15/python_magic.egg-info/dependency_links.txt
--- old/python-magic-0.4.13/python_magic.egg-info/dependency_links.txt  
2017-03-20 07:30:47.000000000 +0100
+++ new/python-magic-0.4.15/python_magic.egg-info/dependency_links.txt  
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/python-magic-0.4.13/python_magic.egg-info/top_level.txt 
new/python-magic-0.4.15/python_magic.egg-info/top_level.txt
--- old/python-magic-0.4.13/python_magic.egg-info/top_level.txt 2017-03-20 
07:30:47.000000000 +0100
+++ new/python-magic-0.4.15/python_magic.egg-info/top_level.txt 1970-01-01 
01:00:00.000000000 +0100
@@ -1 +0,0 @@
-magic
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/setup.cfg 
new/python-magic-0.4.15/setup.cfg
--- old/python-magic-0.4.13/setup.cfg   2017-03-20 07:30:47.000000000 +0100
+++ new/python-magic-0.4.15/setup.cfg   2017-12-04 07:06:41.000000000 +0100
@@ -1,11 +1,5 @@
 [global]
-command_packages = stdeb.command
+command_packages=stdeb.command
 
 [bdist_wheel]
 universal = 1
-
-[egg_info]
-tag_build = 
-tag_date = 0
-tag_svn_revision = 0
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/setup.py 
new/python-magic-0.4.15/setup.py
--- old/python-magic-0.4.13/setup.py    2017-03-20 07:22:59.000000000 +0100
+++ new/python-magic-0.4.15/setup.py    2017-12-04 07:06:41.000000000 +0100
@@ -8,7 +8,7 @@
       author='Adam Hupp',
       author_email='[email protected]',
       url="http://github.com/ahupp/python-magic";,
-      version='0.4.13',
+      version='0.4.15',
       py_modules=['magic'],
       long_description="""This module uses ctypes to access the libmagic file 
type
 identification library.  It makes use of the local magic database and
@@ -22,6 +22,13 @@
           'License :: OSI Approved :: MIT License',
           'Programming Language :: Python',
           'Programming Language :: Python :: 2',
+          'Programming Language :: Python :: 2.6',
+          'Programming Language :: Python :: 2.7',
           'Programming Language :: Python :: 3',
+          'Programming Language :: Python :: 3.3',
+          'Programming Language :: Python :: 3.4',
+          'Programming Language :: Python :: 3.5',
+          'Programming Language :: Python :: 3.6',
+          'Programming Language :: Python :: Implementation :: CPython',
       ],
       )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/stdeb.cfg 
new/python-magic-0.4.15/stdeb.cfg
--- old/python-magic-0.4.13/stdeb.cfg   1970-01-01 01:00:00.000000000 +0100
+++ new/python-magic-0.4.15/stdeb.cfg   2017-12-04 07:06:41.000000000 +0100
@@ -0,0 +1,3 @@
+[python-magic]
+Depends: libmagic1
+Conflicts: python-magic
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/test/run.sh 
new/python-magic-0.4.15/test/run.sh
--- old/python-magic-0.4.13/test/run.sh 2015-07-30 06:54:50.000000000 +0200
+++ new/python-magic-0.4.15/test/run.sh 2017-12-04 07:06:41.000000000 +0100
@@ -1,12 +1,14 @@
 #!/bin/sh
 
-set -e
 
 # ensure we can use unicode filenames in the test
 export LC_ALL=en_US.UTF-8
 THISDIR=`dirname $0`
 export PYTHONPATH=${THISDIR}/..
 
+echo "python2.6"
 python2.6 ${THISDIR}/test.py
+echo "python2.7"
 python2.7 ${THISDIR}/test.py
+echo "python3.0"
 python3 ${THISDIR}/test.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-magic-0.4.13/test/test.py 
new/python-magic-0.4.15/test/test.py
--- old/python-magic-0.4.13/test/test.py        2016-06-06 00:52:11.000000000 
+0200
+++ new/python-magic-0.4.15/test/test.py        2017-12-04 07:06:41.000000000 
+0100
@@ -30,6 +30,13 @@
                     break
             else:
                 self.assertTrue(False, "no match for " + repr(expected_value))
+
+    def test_from_buffer_str_and_bytes(self):
+        m = magic.Magic(mime=True)
+        s = '#!/usr/bin/env python\nprint("foo")'
+        self.assertEqual("text/x-python", m.from_buffer(s))
+        b = b'#!/usr/bin/env python\nprint("foo")'
+        self.assertEqual("text/x-python", m.from_buffer(b))
                 
     def test_mime_types(self):
         dest = os.path.join(MagicTest.TESTDATA_DIR, 
b'\xce\xbb'.decode('utf-8'))
@@ -37,7 +44,7 @@
         try:
             m = magic.Magic(mime=True)
             self.assert_values(m, {
-                'magic.pyc': 'application/octet-stream',
+                'magic._pyc_': 'application/octet-stream',
                 'test.pdf': 'application/pdf',
                 'test.gz': 'application/gzip',
                 'text.txt': 'text/plain',
@@ -52,7 +59,7 @@
         os.environ['TZ'] = 'UTC'  # To get the last modified date of test.gz 
in UTC
         try:
             self.assert_values(m, {
-                'magic.pyc': 'python 2.4 byte-compiled',
+                'magic._pyc_': 'python 2.4 byte-compiled',
                 'test.pdf': 'PDF document, version 1.2',
                 'test.gz':
                 ('gzip compressed data, was "test", from Unix, last modified: 
Sun Jun 29 01:32:52 2008',
Binary files old/python-magic-0.4.13/test/testdata/keep-going.jpg and 
new/python-magic-0.4.15/test/testdata/keep-going.jpg differ
Binary files old/python-magic-0.4.13/test/testdata/magic._pyc_ and 
new/python-magic-0.4.15/test/testdata/magic._pyc_ differ
Binary files old/python-magic-0.4.13/test/testdata/magic.pyc and 
new/python-magic-0.4.15/test/testdata/magic.pyc differ

++++++ magic-new-file.patch ++++++
>From 93492a12aa8ae55e62bce0472e92800eac4b6269 Mon Sep 17 00:00:00 2001
From: Louis Sautier <[email protected]>
Date: Tue, 14 Aug 2018 11:14:19 +0200
Subject: [PATCH] Tests: allow differences when reading a buffer or a file,
 fixes #173

Also remove the loop in order to avoid analyzing files or buffers for each
expected value, replace it with a call to assertIn().
---
 test/test.py | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

Index: python-magic-0.4.15/test/test.py
===================================================================
--- python-magic-0.4.15.orig/test/test.py
+++ python-magic-0.4.15/test/test.py
@@ -11,7 +11,7 @@ import magic
 class MagicTest(unittest.TestCase):
     TESTDATA_DIR = os.path.join(os.path.dirname(__file__), 'testdata')
 
-    def assert_values(self, m, expected_values):
+    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)
@@ -22,15 +22,16 @@ class MagicTest(unittest.TestCase):
             if type(expected_value) is not tuple:
                 expected_value = (expected_value,)
 
-            for i in expected_value:
-                with open(filename, 'rb') as f:
-                    buf_value = m.from_buffer(f.read())
-
-                file_value = m.from_file(filename)
-                if buf_value == i and file_value == i:
-                    break
-            else:
-                self.assertTrue(False, "no match for " + repr(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_buffer_str_and_bytes(self):
         m = magic.Magic(mime=True)
@@ -67,9 +68,11 @@ class MagicTest(unittest.TestCase):
                 ('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'),
+                 ': 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'),
                 'text.txt': 'ASCII text',
-            })
+            }, buf_equals_file=False)
         finally:
             del os.environ['TZ']
 
++++++ magic-new-mime.patch ++++++
>From 4bda684f8b461cc1f69593799efcf6afe8397756 Mon Sep 17 00:00:00 2001
From: Adam Hupp <[email protected]>
Date: Sat, 9 Dec 2017 09:09:00 -0800
Subject: [PATCH] fix test for xenial since travis started enabling it

---
 test/test.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/test.py b/test/test.py
index addccc6..c6e2d9c 100755
--- a/test/test.py
+++ b/test/test.py
@@ -17,7 +17,7 @@ def assert_values(self, m, expected_values):
             except TypeError:
                 filename = os.path.join(self.TESTDATA_DIR.encode('utf-8'), 
filename)
 
-            
+
             if type(expected_value) is not tuple:
                 expected_value = (expected_value,)
 
@@ -37,7 +37,7 @@ def test_from_buffer_str_and_bytes(self):
         self.assertEqual("text/x-python", m.from_buffer(s))
         b = b'#!/usr/bin/env python\nprint("foo")'
         self.assertEqual("text/x-python", m.from_buffer(b))
-                
+
     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)
@@ -92,9 +92,9 @@ def test_keep_going(self):
 
         m = magic.Magic(mime=True)
         self.assertEqual(m.from_file(filename), 'image/jpeg')
-        
+
         m = magic.Magic(mime=True, keep_going=True)
-        self.assertEqual(m.from_file(filename), 'image/jpeg')
+        self.assertEqual(m.from_file(filename), 'image/jpeg\\012- 
application/octet-stream')
 
 
     def test_rethrow(self):
@@ -103,7 +103,7 @@ def test_rethrow(self):
             def t(x,y):
                 raise magic.MagicException("passthrough")
             magic.magic_buffer = t
-            
+
             self.assertRaises(magic.MagicException, magic.from_buffer, 
"hello", True)
         finally:
             magic.magic_buffer = old
++++++ magic-pep8.patch ++++++
>From 828ff0289642a95ec00fe4f9a55da51c455277c8 Mon Sep 17 00:00:00 2001
From: "Guido A.J. Stevens" <[email protected]>
Date: Thu, 25 Jan 2018 08:29:18 +0000
Subject: [PATCH] PEP8

---
 magic.py     | 30 ++++++++++++++++--------------
 test/test.py | 29 ++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/magic.py b/magic.py
index dd86389..83b906d 100644
--- a/magic.py
+++ b/magic.py
@@ -19,7 +19,6 @@
 
 import sys
 import glob
-import os.path
 import ctypes
 import ctypes.util
 import threading
@@ -63,7 +62,7 @@ def __init__(self, mime=False, magic_file=None, 
mime_encoding=False,
 
         self.cookie = magic_open(self.flags)
         self.lock = threading.Lock()
-        
+
         magic_load(self.cookie, magic_file)
 
     def from_buffer(self, buf):
@@ -76,7 +75,7 @@ def from_buffer(self, buf):
                 # otherwise this string is passed as wchar*
                 # which is not what libmagic expects
                 if type(buf) == str and str != bytes:
-                   buf = buf.encode('utf-8', errors='replace')
+                    buf = buf.encode('utf-8', errors='replace')
                 return maybe_decode(magic_buffer(self.cookie, buf))
             except MagicException as e:
                 return self._handle509Bug(e)
@@ -99,7 +98,7 @@ def _handle509Bug(self, e):
             return "application/octet-stream"
         else:
             raise e
-        
+
     def __del__(self):
         # no _thread_check here because there can be no other
         # references to this object at this point.
@@ -117,12 +116,14 @@ def __del__(self):
 
 _instances = {}
 
+
 def _get_magic_type(mime):
     i = _instances.get(mime)
     if i is None:
         i = _instances[mime] = Magic(mime=mime)
     return i
 
+
 def from_file(filename, mime=False):
     """"
     Accepts a filename and returns the detected filetype.  Return
@@ -135,6 +136,7 @@ def from_file(filename, mime=False):
     m = _get_magic_type(mime)
     return m.from_file(filename)
 
+
 def from_buffer(buffer, mime=False):
     """
     Accepts a binary string and returns the detected filetype.  Return
@@ -148,25 +150,25 @@ def from_buffer(buffer, mime=False):
     return m.from_buffer(buffer)
 
 
-
-
 libmagic = None
 # Let's try to find magic or magic1
-dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') 
or ctypes.util.find_library('cygmagic-1')
+dll = ctypes.util.find_library('magic') \
+    or ctypes.util.find_library('magic1') \
+    or ctypes.util.find_library('cygmagic-1')
 
-# This is necessary because find_library returns None if it doesn't find the 
library
+# necessary because find_library returns None if it doesn't find the library
 if dll:
     libmagic = ctypes.CDLL(dll)
 
 if not libmagic or not libmagic._name:
-    windows_dlls = ['magic1.dll','cygmagic-1.dll']
+    windows_dlls = ['magic1.dll', 'cygmagic-1.dll']
     platform_to_lib = {'darwin': ['/opt/local/lib/libmagic.dylib',
                                   '/usr/local/lib/libmagic.dylib'] +
-                         # Assumes there will only be one version installed
-                         
glob.glob('/usr/local/Cellar/libmagic/*/lib/libmagic.dylib'),
+                       # Assumes there will only be one version installed
+                       
glob.glob('/usr/local/Cellar/libmagic/*/lib/libmagic.dylib'),  # flake8:noqa
                        'win32': windows_dlls,
                        'cygwin': windows_dlls,
-                       'linux': ['libmagic.so.1'],    # fallback for some 
Linuxes (e.g. Alpine) where library search does not work
+                       'linux': ['libmagic.so.1'],  # fallback for some 
Linuxes (e.g. Alpine) where library search does not work # flake8:noqa
                       }
     platform = 'linux' if sys.platform.startswith('linux') else sys.platform
     for dll in platform_to_lib.get(platform, []):
@@ -204,13 +206,13 @@ def maybe_decode(s):
         return s
     else:
         return s.decode('utf-8')
-    
+
 def coerce_filename(filename):
     if filename is None:
         return None
 
     # ctypes will implicitly convert unicode strings to bytes with
-    # .encode('ascii').  If you use the filesystem encoding 
+    # .encode('ascii').  If you use the filesystem encoding
     # then you'll get inconsistent behavior (crashes) depending on the user's
     # LANG environment variable
     is_unicode = (sys.version_info[0] <= 2 and
diff --git a/test/test.py b/test/test.py
index c6e2d9c..a92972b 100755
--- a/test/test.py
+++ b/test/test.py
@@ -1,4 +1,4 @@
-import os, sys
+import os
 # for output which reports a local time
 os.environ['TZ'] = 'GMT'
 import shutil
@@ -7,6 +7,7 @@
 
 import magic
 
+
 class MagicTest(unittest.TestCase):
     TESTDATA_DIR = os.path.join(os.path.dirname(__file__), 'testdata')
 
@@ -15,8 +16,8 @@ def assert_values(self, m, expected_values):
             try:
                 filename = os.path.join(self.TESTDATA_DIR, filename)
             except TypeError:
-                filename = os.path.join(self.TESTDATA_DIR.encode('utf-8'), 
filename)
-
+                filename = os.path.join(
+                    self.TESTDATA_DIR.encode('utf-8'), filename)
 
             if type(expected_value) is not tuple:
                 expected_value = (expected_value,)
@@ -39,7 +40,8 @@ def test_from_buffer_str_and_bytes(self):
         self.assertEqual("text/x-python", m.from_buffer(b))
 
     def test_mime_types(self):
-        dest = os.path.join(MagicTest.TESTDATA_DIR, 
b'\xce\xbb'.decode('utf-8'))
+        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)
@@ -56,14 +58,16 @@ def test_mime_types(self):
 
     def test_descriptions(self):
         m = magic.Magic()
-        os.environ['TZ'] = 'UTC'  # To get the last modified date of test.gz 
in UTC
+        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',
                 '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", 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'),
                 'text.txt': 'ASCII text',
             })
         finally:
@@ -94,18 +98,21 @@ def test_keep_going(self):
         self.assertEqual(m.from_file(filename), 'image/jpeg')
 
         m = magic.Magic(mime=True, keep_going=True)
-        self.assertEqual(m.from_file(filename), 'image/jpeg\\012- 
application/octet-stream')
-
+        self.assertEqual(m.from_file(filename),
+                         'image/jpeg\\012- application/octet-stream')
 
     def test_rethrow(self):
         old = magic.magic_buffer
         try:
-            def t(x,y):
+            def t(x, y):
                 raise magic.MagicException("passthrough")
             magic.magic_buffer = t
 
-            self.assertRaises(magic.MagicException, magic.from_buffer, 
"hello", True)
+            with self.assertRaises(magic.MagicException):
+                magic.from_buffer("hello", True)
         finally:
             magic.magic_buffer = old
+
+
 if __name__ == '__main__':
     unittest.main()
++++++ magic-tests.patch ++++++
>From e83487a20bacd4f9b33d0478861671bf79468f59 Mon Sep 17 00:00:00 2001
From: Louis Sautier <[email protected]>
Date: Mon, 13 Aug 2018 12:15:13 +0200
Subject: [PATCH] Allow x-gzip as MIME type for gzip files, fixes #96

---
 test/test.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test.py b/test/test.py
index e29335f..e3ee703 100755
--- a/test/test.py
+++ b/test/test.py
@@ -54,7 +54,7 @@ def test_mime_types(self):
             self.assert_values(m, {
                 'magic._pyc_': 'application/octet-stream',
                 'test.pdf': 'application/pdf',
-                'test.gz': 'application/gzip',
+                'test.gz': ('application/gzip', 'application/x-gzip'),
                 'text.txt': 'text/plain',
                 b'\xce\xbb'.decode('utf-8'): 'text/plain',
                 b'\xce\xbb': 'text/plain',

Reply via email to