summaryrefslogtreecommitdiffstats
path: root/tests/identify_test.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-12 21:19:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-12 21:20:17 +0000
commit0ece75006ba491182e21cc1234c8e958cc9744f0 (patch)
treebefc84c7c2e47ff88a0e490cdf80edc7aa140b92 /tests/identify_test.py
parentReleasing debian version 2.1.0-1. (diff)
downloadidentify-0ece75006ba491182e21cc1234c8e958cc9744f0.tar.xz
identify-0ece75006ba491182e21cc1234c8e958cc9744f0.zip
Merging upstream version 2.1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/identify_test.py')
-rw-r--r--tests/identify_test.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/identify_test.py b/tests/identify_test.py
index 8cc5856..f881f0b 100644
--- a/tests/identify_test.py
+++ b/tests/identify_test.py
@@ -1,8 +1,11 @@
+import builtins
+import errno
import io
import os
import socket
import stat
from tempfile import TemporaryDirectory
+from unittest import mock
import pytest
@@ -330,6 +333,15 @@ def test_parse_shebang_from_file_simple(tmpdir):
assert identify.parse_shebang_from_file(x.strpath) == ('python',)
+def test_parse_shebang_open_raises_einval(tmpdir):
+ x = tmpdir.join('f')
+ x.write('#!/usr/bin/env not-expected\n')
+ make_executable(x)
+ error = OSError(errno.EINVAL, f'Invalid argument {x}')
+ with mock.patch.object(builtins, 'open', side_effect=error):
+ assert identify.parse_shebang_from_file(x.strpath) == ()
+
+
def make_executable(filename):
original_mode = os.stat(filename).st_mode
os.chmod(