summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-04 15:04:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-04 15:04:29 +0000
commitdb009d021fe4053a5438f97675b68d540b3fb9ec (patch)
tree21d30e8ede2a78657c56937a508f97b828ed7c9d /tests
parentAdding upstream version 1.5.14. (diff)
downloadidentify-db009d021fe4053a5438f97675b68d540b3fb9ec.tar.xz
identify-db009d021fe4053a5438f97675b68d540b3fb9ec.zip
Adding upstream version 2.1.0.upstream/2.1.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/cli_test.py4
-rw-r--r--tests/extensions_test.py4
-rw-r--r--tests/identify_test.py38
3 files changed, 31 insertions, 15 deletions
diff --git a/tests/cli_test.py b/tests/cli_test.py
index 9369a5e..94fb8ae 100644
--- a/tests/cli_test.py
+++ b/tests/cli_test.py
@@ -1,7 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
from identify import cli
diff --git a/tests/extensions_test.py b/tests/extensions_test.py
index 4527a58..c2a828c 100644
--- a/tests/extensions_test.py
+++ b/tests/extensions_test.py
@@ -1,7 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
import pytest
from identify import extensions
diff --git a/tests/identify_test.py b/tests/identify_test.py
index 8e00f60..8cc5856 100644
--- a/tests/identify_test.py
+++ b/tests/identify_test.py
@@ -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),