Merging upstream version 2.1.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
9011a461b8
commit
2a78ba5ef7
4 changed files with 23 additions and 3 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue