diff options
author | Adam Hupp <adam@hupp.org> | 2021-01-15 13:49:55 -0800 |
---|---|---|
committer | Adam Hupp <adam@hupp.org> | 2021-01-15 13:49:55 -0800 |
commit | 2b8bb0d68eff1293050f10fec26cef38b4dfd282 (patch) | |
tree | 54b4bb5d2691e533e72d77048ad653e90ecaac8b | |
parent | c6457815ee61581e9addf47fb75f9b550e06fcce (diff) | |
download | python-magic-2b8bb0d68eff1293050f10fec26cef38b4dfd282.tar.gz |
skip magic_descriptor tests in centos 7
-rw-r--r-- | test/Dockerfile_centos7 | 2 | ||||
-rw-r--r-- | test/libmagic_test.py | 9 | ||||
-rw-r--r-- | test/run.py | 5 | ||||
-rwxr-xr-x | test/test.py | 10 |
4 files changed, 22 insertions, 4 deletions
diff --git a/test/Dockerfile_centos7 b/test/Dockerfile_centos7 index 8620e7e..f2ac6e4 100644 --- a/test/Dockerfile_centos7 +++ b/test/Dockerfile_centos7 @@ -2,4 +2,4 @@ FROM centos:7 RUN yum -y update RUN yum -y install file-devel python3 python2 which COPY . /python-magic -CMD cd /python-magic/test && python3 ./run.py +CMD cd /python-magic/test && SKIP_FROM_DESCRIPTOR=1 python3 ./run.py diff --git a/test/libmagic_test.py b/test/libmagic_test.py index e1623b4..64b7ec4 100644 --- a/test/libmagic_test.py +++ b/test/libmagic_test.py @@ -1,9 +1,11 @@ # coding: utf-8 import unittest - +import os import magic +# magic_descriptor is broken (?) in centos 7, so don't run those tests +SKIP_FROM_DESCRIPTOR = bool(os.environ.get('SKIP_FROM_DESCRIPTOR')) class MagicTestCase(unittest.TestCase): filename = 'testdata/test.pdf' @@ -21,6 +23,11 @@ class MagicTestCase(unittest.TestCase): self.assert_result(result) def test_detect_from_fobj(self): + + if SKIP_FROM_DESCRIPTOR: + self.skipTest("magic_descriptor is broken in this version of libmagic") + + with open(self.filename) as fobj: result = magic.detect_from_fobj(fobj) self.assert_result(result) diff --git a/test/run.py b/test/run.py index c4b8d0a..cf62eee 100644 --- a/test/run.py +++ b/test/run.py @@ -4,10 +4,11 @@ import sys this_dir = os.path.dirname(sys.argv[0]) -new_env = { +new_env = dict(os.environ) +new_env.update({ 'LC_ALL': 'en_US.UTF-8', 'PYTHONPATH': os.path.join(this_dir, ".."), -} +}) def has_py(version): diff --git a/test/test.py b/test/test.py index ec479f0..e333641 100755 --- a/test/test.py +++ b/test/test.py @@ -15,6 +15,8 @@ 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') @@ -59,6 +61,9 @@ class MagicTest(unittest.TestCase): 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', @@ -67,6 +72,8 @@ class MagicTest(unittest.TestCase): 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( @@ -77,6 +84,9 @@ class MagicTest(unittest.TestCase): in ("text/x-python", "text/x-script.python")) def test_open_file(self): + if SKIP_FROM_DESCRIPTOR: + self.skipTest("magic_descriptor is broken in this version of libmagic") + m = magic.Magic(mime=True) filename = os.path.join(self.TESTDATA_DIR, "test.pdf") with open(filename) as f: |