1
0
Fork 0

Merging upstream version 2.1.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-12 21:44:30 +01:00
parent cbed83fde7
commit ae97967170
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
14 changed files with 132 additions and 104 deletions

View file

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
from identify import cli

View file

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import pytest
from identify import extensions

View file

@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import io
import os
import socket
import stat
from tempfile import TemporaryDirectory
import pytest
@ -14,6 +12,21 @@ from identify import identify
def test_all_tags_includes_basic_ones():
assert 'file' in identify.ALL_TAGS
assert 'directory' in identify.ALL_TAGS
assert 'executable' in identify.ALL_TAGS
assert 'text' in identify.ALL_TAGS
assert 'socket' in identify.ALL_TAGS
@pytest.mark.parametrize(
'tag_group',
(
identify.TYPE_TAGS,
identify.MODE_TAGS,
identify.ENCODING_TAGS,
),
)
def test_all_tags_contains_all_groups(tag_group):
assert tag_group < identify.ALL_TAGS
def test_all_tags_contains_each_type():
@ -41,6 +54,17 @@ def test_tags_from_path_symlink(tmpdir):
assert identify.tags_from_path(x.strpath) == {'symlink'}
def test_tags_from_path_socket():
tmproot = '/tmp' # short path avoids `OSError: AF_UNIX path too long`
with TemporaryDirectory(dir=tmproot) as tmpdir:
socket_path = os.path.join(tmpdir, 'socket')
with socket.socket(socket.AF_UNIX) as sock:
sock.bind(socket_path)
tags = identify.tags_from_path(socket_path)
assert tags == {'socket'}
def test_tags_from_path_broken_symlink(tmpdir):
x = tmpdir.join('foo')
x.mksymlinkto(tmpdir.join('lol'))
@ -177,9 +201,9 @@ def test_tags_from_interpreter(interpreter, expected):
(
(b'hello world', True),
(b'', True),
('éóñəå ⊂(◉‿◉)つ(ノ≥∇≤)'.encode('utf8'), True),
(r'¯\_(ツ)_/¯'.encode('utf8'), True),
('♪┏(・o・)┛♪┗ ( ・o・) ┓♪┏ ( ) ┛♪┗ (・o・ ) ┓♪'.encode('utf8'), True),
('éóñəå ⊂(◉‿◉)つ(ノ≥∇≤)'.encode(), True),
(r'¯\_(ツ)_/¯'.encode(), True),
('♪┏(・o・)┛♪┗ ( ・o・) ┓♪┏ ( ) ┛♪┗ (・o・ ) ┓♪'.encode(), True),
('éóñå'.encode('latin1'), True),
(b'hello world\x00', False),