repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline def _test_conf(conf, **kwargs): op...
[4]
assert
collection
test/test_auditconf.py
test_audit_conf_ip_version_preference
TestAuditConf
66
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_level(self, output_spy): out = self.OutputBuffer() # visible: all out.level = 'info' output_spy.begin() out.info('info color') ...
5
assert
numeric_literal
test/test_outputbuffer.py
test_outputbuffer_level
TestOutputBuffer
128
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_no_lines(self, output_spy): output_spy.begin() obuf = self.OutputBuffer() obuf.write() assert output_spy.flush() ==
['']
assert
collection
test/test_outputbuffer.py
test_outputbuffer_no_lines
TestOutputBuffer
14
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def test_timefra...
len(str(tf2))
assert
func_call
test/test_algorithm.py
test_timeframe_creation
TestAlgorithm
123
null
jtesta/ssh-audit
import os import struct import pytest from ssh_audit.auditconf import AuditConf from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.protocol import Protocol from ssh_audit.readbuf import ReadBuf from ssh_audit.ssh2_kex import SSH2_Kex from ssh_audit.ssh2_kexparty import SSH2_KexParty from ssh_audit.ssh_audi...
74
assert
numeric_literal
test/test_ssh2.py
test_ssh2_server_simple
TestSSH2
168
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh2_kexdb import SSH2_KexDB class Test_SSH2_KexDB: def init(self): self.db = SSH2_KexDB.get_db() self.pq_warning = SSH2_KexDB.WARN_NOT_PQ_SAFE def test_kex_pq_unsafe(self): '''Ensures that all key exchange algorithms are marked as post-quantum unsafe, un...
[]
assert
collection
test/test_ssh2_kexdb.py
test_kex_pq_unsafe
Test_SSH2_KexDB
73
null
jtesta/ssh-audit
import re import pytest from ssh_audit.readbuf import ReadBuf from ssh_audit.writebuf import WriteBuf class TestBuffer: def init(self, ssh_audit): self.rbuf = ReadBuf self.wbuf = WriteBuf self.utf8rchar = b'\xef\xbf\xbd' def _b(cls, v): v = re.sub(r'\s', '', v) data =...
8
assert
numeric_literal
test/test_buffer.py
test_reset
TestBuffer
140
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def test_get_ssh...
('OpenSSH', '7.5', False)
assert
collection
test/test_algorithm.py
test_get_ssh_version
TestAlgorithm
21
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh2_kexdb import SSH2_KexDB class Test_SSH2_KexDB: def init(self): self.db = SSH2_KexDB.get_db() self.pq_warning = SSH2_KexDB.WARN_NOT_PQ_SAFE def test_ssh2_kexdb(self): '''Ensures that the SSH2_KexDB.ALGORITHMS dictionary is in the right format.''' ...
len(alg_data)
assert
func_call
test/test_ssh2_kexdb.py
test_ssh2_kexdb
Test_SSH2_KexDB
32
null
jtesta/ssh-audit
import re import pytest from ssh_audit.readbuf import ReadBuf from ssh_audit.writebuf import WriteBuf class TestBuffer: def init(self, ssh_audit): self.rbuf = ReadBuf self.wbuf = WriteBuf self.utf8rchar = b'\xef\xbf\xbd' def _b(cls, v): v = re.sub(r'\s', '', v) data =...
5
assert
numeric_literal
test/test_buffer.py
test_unread
TestBuffer
25
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_level_property(self): out = self.OutputBuffer() out.level = 'info' assert out.level == 'info' out.level = 'good' assert out.level =...
'unknown'
assert
string_literal
test/test_outputbuffer.py
test_outputbuffer_level_property
TestOutputBuffer
115
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_levels(self): out = self.OutputBuffer() assert out.get_level('info') ==
0
assert
numeric_literal
test/test_outputbuffer.py
test_outputbuffer_levels
TestOutputBuffer
98
null
jtesta/ssh-audit
import pytest class TestUtils: def init(self, ssh_audit): self.utils = ssh_audit.Utils def test_is_ascii(self): assert self.utils.is_ascii('francais') is
True
assert
bool_literal
test/test_utils.py
test_is_ascii
TestUtils
25
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline def _test_conf(conf, **kwargs): op...
[]
assert
collection
test/test_auditconf.py
test_audit_conf_ip_version_preference
TestAuditConf
91
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def test_get_sin...
'available since Dropbear SSH 2016.73'
assert
string_literal
test/test_algorithm.py
test_get_since_text
TestAlgorithm
34
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline def _test_conf(conf, **kwargs): op...
SystemExit)
pytest.raises
variable
test/test_auditconf.py
test_audit_conf_process_commandline
TestAuditConf
106
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def test_get_sin...
None
assert
none_literal
test/test_algorithm.py
test_get_since_text
TestAlgorithm
36
null
jtesta/ssh-audit
import pytest from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.ssh_socket import SSH_Socket class TestSocket: def init(self, ssh_audit): self.OutputBuffer = OutputBuffer self.ssh_socket = SSH_Socket def test_not_connected_socket(self, virtual_socket): sock = self.ssh_so...
0
assert
numeric_literal
test/test_socket.py
test_not_connected_socket
TestSocket
32
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_levels(self): out = self.OutputBuffer() assert out.get_level('info') == 0 assert out.get_level('good') == 0 assert out.get_level('warn') =...
1
assert
numeric_literal
test/test_outputbuffer.py
test_outputbuffer_levels
TestOutputBuffer
100
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def test_get_ssh...
''
assert
string_literal
test/test_algorithm.py
test_get_ssh_version
TestAlgorithm
25
null
jtesta/ssh-audit
import pytest from ssh_audit.banner import Banner from ssh_audit.software import Software class TestVersionCompare: def init(self, ssh_audit): self.software = Software self.banner = Banner def get_dropbear_software(self, v): b = self.banner.parse('SSH-2.0-dropbear_{}'.format(v)) ...
0
assert
numeric_literal
test/test_version_compare.py
test_dropbear_compare_version_pre_years
TestVersionCompare
30
null
jtesta/ssh-audit
import pytest from ssh_audit.banner import Banner class TestBanner: def init(self, ssh_audit): self.banner = Banner def test_simple_banners(self): banner = lambda x: self.banner.parse(x) # noqa b = banner('SSH-2.0-OpenSSH_7.3') assert b.protocol == (2, 0) assert b.so...
None
assert
none_literal
test/test_banner.py
test_simple_banners
TestBanner
17
null
jtesta/ssh-audit
import pytest from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.ssh_socket import SSH_Socket class TestSocket: def init(self, ssh_audit): self.OutputBuffer = OutputBuffer self.ssh_socket = SSH_Socket def test_invalid_host(self, virtual_socket): with pytest.raises(
ValueError)
pytest.raises
variable
test/test_socket.py
test_invalid_host
TestSocket
15
null
jtesta/ssh-audit
import socket import pytest class TestResolve: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.audit = ssh_audit.audit self.OutputBuffer = ssh_audit.OutputBuffer self.ssh_socket = ssh_audit.SSH_Socket def _conf(self): conf = self.AuditConf('localho...
1
assert
numeric_literal
test/test_resolve.py
test_resolve_ipv4
TestResolve
46
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline @staticmethod def _test_conf(conf, **k...
options['port']
assert
complex_expr
test/test_auditconf.py
_test_conf
TestAuditConf
28
null
jtesta/ssh-audit
import socket import errno import pytest from ssh_audit.outputbuffer import OutputBuffer class TestErrors: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer self.audit = ssh_audit.audit def _conf(self): conf = self.Audi...
2
assert
numeric_literal
test/test_errors.py
test_connection_closed_after_banner
TestErrors
125
null
jtesta/ssh-audit
import re import pytest from ssh_audit.readbuf import ReadBuf from ssh_audit.writebuf import WriteBuf class TestBuffer: def init(self, ssh_audit): self.rbuf = ReadBuf self.wbuf = WriteBuf self.utf8rchar = b'\xef\xbf\xbd' def _b(cls, v): v = re.sub(r'\s', '', v) data =...
self._b(p[1])
assert
func_call
test/test_buffer.py
test_mpint2
TestBuffer
132
null
jtesta/ssh-audit
import pytest class TestUtils: def init(self, ssh_audit): self.utils = ssh_audit.Utils def test_to_ascii(self): assert self.utils.to_ascii('francais') == 'francais' assert self.utils.to_ascii('fran\xe7ais') == 'fran?ais' assert self.utils.to_ascii('fran\xe7ais', 'ignore') ==
'franais'
assert
string_literal
test/test_utils.py
test_to_ascii
TestUtils
33
null
jtesta/ssh-audit
import pytest from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.ssh_socket import SSH_Socket class TestSocket: def init(self, ssh_audit): self.OutputBuffer = OutputBuffer self.ssh_socket = SSH_Socket def test_not_connected_socket(self, virtual_socket): sock = self.ssh_so...
None
assert
none_literal
test/test_socket.py
test_not_connected_socket
TestSocket
31
null
jtesta/ssh-audit
import os import struct import pytest from ssh_audit.auditconf import AuditConf from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.protocol import Protocol from ssh_audit.readbuf import ReadBuf from ssh_audit.ssh2_kex import SSH2_Kex from ssh_audit.ssh2_kexparty import SSH2_KexParty from ssh_audit.ssh_audi...
kex2.payload
assert
complex_expr
test/test_ssh2.py
test_key_payload
TestSSH2
154
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def test_timefra...
tf
assert
variable
test/test_algorithm.py
test_timeframe_object
TestAlgorithm
131
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_level(self, output_spy): out = self.OutputBuffer() # visible: all out.level = 'info' output_spy.begin() out.info('info color') ...
3
assert
numeric_literal
test/test_outputbuffer.py
test_outputbuffer_level
TestOutputBuffer
138
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_defaults(self): obuf = self.OutputBuffer() # default: on assert obuf.batch is
False
assert
bool_literal
test/test_outputbuffer.py
test_outputbuffer_defaults
TestOutputBuffer
20
null
jtesta/ssh-audit
import pytest class TestUtils: def init(self, ssh_audit): self.utils = ssh_audit.Utils def test_parse_float(self): assert self.utils.parse_float('5.x') ==
-1.0
assert
numeric_literal
test/test_utils.py
test_parse_float
TestUtils
72
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline def _test_conf(conf, **kwargs): op...
False
assert
bool_literal
test/test_auditconf.py
test_audit_conf_booleans
TestAuditConf
48
null
jtesta/ssh-audit
import hashlib import pytest from datetime import date from ssh_audit.builtin_policies import BUILTIN_POLICIES from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.policy import Policy from ssh_audit.ssh2_kex import SSH2_Kex from ssh_audit.writebuf import WriteBuf class TestPolicy: def init(self, ssh_a...
0
assert
numeric_literal
test/test_policy.py
test_builtin_policy_consistency
TestPolicy
140
null
jtesta/ssh-audit
import re import pytest from ssh_audit.readbuf import ReadBuf from ssh_audit.writebuf import WriteBuf class TestBuffer: def init(self, ssh_audit): self.rbuf = ReadBuf self.wbuf = WriteBuf self.utf8rchar = b'\xef\xbf\xbd' def _b(cls, v): v = re.sub(r'\s', '', v) data =...
v
assert
variable
test/test_buffer.py
test_string
TestBuffer
72
null
jtesta/ssh-audit
import pytest class TestOutputBuffer: def init(self, ssh_audit): self.OutputBuffer = ssh_audit.OutputBuffer def test_outputbuffer_defaults(self): obuf = self.OutputBuffer() # default: on assert obuf.batch is False assert obuf.use_colors is
True
assert
bool_literal
test/test_outputbuffer.py
test_outputbuffer_defaults
TestOutputBuffer
21
null
jtesta/ssh-audit
import pytest from ssh_audit.banner import Banner class TestBanner: def init(self, ssh_audit): self.banner = Banner def test_banners_with_multiple_protocols(self): b = lambda x: self.banner.parse(x) # noqa assert str(b('SSH-1.99-SSH-1.99-OpenSSH_3.6.1p2')) == 'SSH-1.99-OpenSSH_3.6.1...
'SSH-1.99-OpenSSH_3.9p1'
assert
string_literal
test/test_banner.py
test_banners_with_multiple_protocols
TestBanner
69
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline @staticmethod def _test_conf(conf, **k...
options['host']
assert
complex_expr
test/test_auditconf.py
_test_conf
TestAuditConf
27
null
jtesta/ssh-audit
import socket import pytest class TestResolve: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.audit = ssh_audit.audit self.OutputBuffer = ssh_audit.OutputBuffer self.ssh_socket = ssh_audit.SSH_Socket def _conf(self): conf = self.AuditConf('localho...
(socket.AF_INET, ('127.0.0.1', 22))
assert
collection
test/test_resolve.py
test_resolve_ipv4
TestResolve
47
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def test_get_ssh...
('OpenSSH', '7.5', True)
assert
collection
test/test_algorithm.py
test_get_ssh_version
TestAlgorithm
22
null
jtesta/ssh-audit
import hashlib import pytest from datetime import date from ssh_audit.builtin_policies import BUILTIN_POLICIES from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.policy import Policy from ssh_audit.ssh2_kex import SSH2_Kex from ssh_audit.writebuf import WriteBuf class TestPolicy: def init(self, ssh_a...
4
assert
numeric_literal
test/test_policy.py
test_policy_evaluate_subset_failing_1
TestPolicy
500
null
jtesta/ssh-audit
import re import pytest from ssh_audit.readbuf import ReadBuf from ssh_audit.writebuf import WriteBuf class TestBuffer: def init(self, ssh_audit): self.rbuf = ReadBuf self.wbuf = WriteBuf self.utf8rchar = b'\xef\xbf\xbd' def _b(cls, v): v = re.sub(r'\s', '', v) data =...
6
assert
numeric_literal
test/test_buffer.py
test_bitlen
TestBuffer
107
null
jtesta/ssh-audit
import pytest from ssh_audit.banner import Banner from ssh_audit.software import Software class TestSoftware: def init(self, ssh_audit): self.software = Software self.banner = Banner def test_unknown_software(self): ps = lambda x: self.software.parse(self.banner.parse(x)) # noqa ...
None
assert
none_literal
test/test_software.py
test_unknown_software
TestSoftware
16
null
jtesta/ssh-audit
import pytest from ssh_audit.algorithm import Algorithm from ssh_audit.timeframe import Timeframe class TestAlgorithm: def init(self, ssh_audit): self.algorithm = Algorithm self.timeframe = Timeframe def _tf(self, v, s=None): return self.timeframe().update(v, s) def cmp_tf(v...
str(r)
assert
func_call
test/test_algorithm.py
cmp_tf
TestAlgorithm
42
null
jtesta/ssh-audit
import pytest class TestUtils: def init(self, ssh_audit): self.utils = ssh_audit.Utils def test_is_ascii(self): assert self.utils.is_ascii('francais') is True assert self.utils.is_ascii('fran\xe7ais') is
False
assert
bool_literal
test/test_utils.py
test_is_ascii
TestUtils
26
null
jtesta/ssh-audit
import os import struct import pytest from ssh_audit.auditconf import AuditConf from ssh_audit.outputbuffer import OutputBuffer from ssh_audit.protocol import Protocol from ssh_audit.readbuf import ReadBuf from ssh_audit.ssh2_kex import SSH2_Kex from ssh_audit.ssh2_kexparty import SSH2_KexParty from ssh_audit.ssh_audi...
None
assert
none_literal
test/test_ssh2.py
test_kex_read
TestSSH2
84
null
jtesta/ssh-audit
import pytest class TestUtils: def init(self, ssh_audit): self.utils = ssh_audit.Utils def test_ctoi(self): assert self.utils.ctoi(123) ==
123
assert
numeric_literal
test/test_utils.py
test_ctoi
TestUtils
55
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline def _test_conf(conf, **kwargs): op...
port
assert
variable
test/test_auditconf.py
test_audit_conf_port
TestAuditConf
54
null
jtesta/ssh-audit
import pytest from ssh_audit.ssh_audit import process_commandline class TestAuditConf: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.OutputBuffer = ssh_audit.OutputBuffer() self.process_commandline = process_commandline def _test_conf(conf, **kwargs): op...
True
assert
bool_literal
test/test_auditconf.py
test_audit_conf_ip_version_preference
TestAuditConf
64
null
jtesta/ssh-audit
import socket import pytest class TestResolve: def init(self, ssh_audit): self.AuditConf = ssh_audit.AuditConf self.audit = ssh_audit.audit self.OutputBuffer = ssh_audit.OutputBuffer self.ssh_socket = ssh_audit.SSH_Socket def _conf(self): conf = self.AuditConf('localho...
0
assert
numeric_literal
test/test_resolve.py
test_resolve_hostname_without_records
TestResolve
39
null
xavctn/img2table
import os import cv2 import polars as pl import pytest from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.ocr.data import OCRDataframe from tests import MOCK_DIR, TESSERACT_INSTALL def test_validators(): with pytest.raises(
TypeError)
pytest.raises
variable
tests/ocr/tesseract/test_tesseract.py
test_validators
15
null
xavctn/img2table
from io import BytesIO import pytest from openpyxl import load_workbook from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_image_excel(mock_tesseract): ocr = TesseractOCR() img = Image(src="test_data/test.png", ...
expected.worksheets[idx].title
assert
complex_expr
tests/document/image/test_image.py
test_image_excel
106
null
xavctn/img2table
import json import polars as pl import pytest from img2table.document.image import Image from img2table.ocr.data import OCRDataframe from tests.conftest import nested_approx def test_paddle_ocr_df(): from img2table.ocr import PaddleOCR instance = PaddleOCR() with open("test_data/hocr.json", "r") as f: ...
expected
assert
variable
tests/ocr/paddle/test_paddle.py
test_paddle_ocr_df
46
null
xavctn/img2table
import cv2 from img2table.tables import threshold_dark_areas from img2table.tables.metrics import compute_char_length, compute_median_line_sep, compute_img_metrics def test_compute_median_line_sep(): image = cv2.cvtColor(cv2.imread("test_data/test.png"), cv2.COLOR_BGR2RGB) thresh = threshold_dark_areas(img=im...
71
assert
numeric_literal
tests/tables/image/test_metrics.py
test_compute_median_line_sep
30
null
xavctn/img2table
import json import sys from typing import Any import numpy as np import polars as pl import pytest from img2table.document.image import Image from img2table.ocr import EasyOCR from img2table.ocr.data import OCRDataframe def convert_np_types(obj: Any): if isinstance(obj, list): return [convert_np_types(el...
convert_np_types(expected)
assert
func_call
tests/ocr/easyocr/test_easyocr.py
test_easyocr_content
47
null
xavctn/img2table
from img2table.tables.objects.cell import Cell from img2table.tables.objects.row import Row def test_row(): row = Row(cells=[Cell(x1=0, x2=20, y1=0, y2=20), Cell(x1=20, x2=40, y1=0, y2=20)]) assert row.x1 == 0 assert row.y1 == 0 assert row.x2 == 40 assert row.y2 ==
20
assert
numeric_literal
tests/tables/objects/test_row.py
test_row
12
null
xavctn/img2table
import json import cv2 from img2table.tables import threshold_dark_areas from img2table.tables.objects.line import Line from img2table.tables.processing.borderless_tables import segment_image def test_segment_image(): img = cv2.cvtColor(cv2.imread("test_data/test.bmp"), cv2.COLOR_BGR2RGB) thresh = threshold_...
4
assert
numeric_literal
tests/tables/processing/borderless_tables/layout/test_layout.py
test_segment_image
30
null
xavctn/img2table
from io import BytesIO import pytest from openpyxl import load_workbook from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_no_ocr(): img = Image(src="test_data/dark.png", detect_rotation=True) result...
1
assert
numeric_literal
tests/document/image/test_image.py
test_no_ocr
87
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.processing.borderless_tables.model import ColumnGroup, Column, VerticalWS, Whitespace from img2table.tables.processing.borderless_tables.rows import \ identify_delimiter_group_rows, identify_row_delimiters, filter_coherent_row_delimit...
45
assert
numeric_literal
tests/tables/processing/borderless_tables/rows/test_rows.py
test_identify_delimiter_group_rows
84
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.processing.borderless_tables.model import ColumnGroup, Column, VerticalWS, Whitespace from img2table.tables.processing.borderless_tables.rows import \ identify_delimiter_group_rows, identify_row_delimiters, filter_coherent_row_delimit...
93
assert
numeric_literal
tests/tables/processing/borderless_tables/rows/test_rows.py
test_identify_delimiter_group_rows
86
null
xavctn/img2table
from img2table.tables.objects.cell import Cell from img2table.tables.objects.row import Row def test_add_cells(): row = Row(cells=[Cell(x1=0, x2=20, y1=0, y2=20), Cell(x1=20, x2=40, y1=0, y2=20)]) row.add_cells(cells=Cell(x1=40, x2=60, y1=0, y2=20)) assert row.nb_columns ==
3
assert
numeric_literal
tests/tables/objects/test_row.py
test_add_cells
22
null
xavctn/img2table
import os import pickle import polars as pl import pytest from img2table.document import Image from img2table.ocr import AzureOCR from img2table.ocr.data import OCRDataframe from tests import MOCK_DIR def test_content(mock_azure): img = Image("test_data/test.png") ocr = AzureOCR(endpoint="aa", subscription_k...
[expected]
assert
collection
tests/ocr/azure/test_azure.py
test_content
23
null
xavctn/img2table
import os import pickle import sys import polars as pl import pytest from img2table.document import Image from img2table.ocr import SuryaOCR from img2table.ocr.data import OCRDataframe from tests import MOCK_DIR @pytest.mark.skipif(sys.version_info < (3, 10), reason="Library not available") def test_surya_ocr(mock_s...
TypeError)
pytest.raises
variable
tests/ocr/surya/test_surya.py
test_surya_ocr
44
null
xavctn/img2table
import sys from io import BytesIO import pytest from img2table.document.pdf import PDF from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_pdf_pages(): assert len(list(PDF(src="test_data/test.pdf").images)) ==
2
assert
numeric_literal
tests/document/pdf/test_pdf.py
test_pdf_pages
44
null
xavctn/img2table
import json import polars as pl from img2table.ocr.data import OCRDataframe from img2table.tables.objects.cell import Cell from img2table.tables.objects.row import Row from img2table.tables.objects.table import Table def test_remove_rows(): table = Table(rows=[Row(cells=[Cell(x1=0, x2=100, y1=0, y2=10)]), ...
expected
assert
variable
tests/tables/objects/test_table.py
test_remove_rows
21
null
xavctn/img2table
import json import polars as pl import pytest from img2table.document.image import Image from img2table.ocr.data import OCRDataframe from tests.conftest import nested_approx def test_validators(): from img2table.ocr import PaddleOCR with pytest.raises(
TypeError)
pytest.raises
variable
tests/ocr/paddle/test_paddle.py
test_validators
16
null
xavctn/img2table
from img2table.tables.objects.cell import Cell from img2table.tables.objects.row import Row def test_split_in_rows(): row = Row(cells=[Cell(x1=0, x2=20, y1=0, y2=20), Cell(x1=20, x2=40, y1=0, y2=20)]) rows_splitted = row.split_in_rows(vertical_delimiters=[10, 15]) expected = [Row(cells=[Cell(x1=0, x2=20,...
expected
assert
variable
tests/tables/objects/test_row.py
test_split_in_rows
36
null
xavctn/img2table
import json import polars as pl from img2table.tables.objects.cell import Cell from img2table.tables.objects.line import Line from img2table.tables.processing.bordered_tables.cells import get_cells def test_get_cells(): with open("test_data/lines.json", 'r') as f: data = json.load(f) h_lines = [Line(...
sorted(expected, key=lambda c: (c.x1, c.y1, c.x2, c.y2))
assert
func_call
tests/tables/processing/bordered_tables/cells/test_cells.py
test_get_cells
24
null
xavctn/img2table
from img2table.tables.objects.cell import Cell from img2table.tables.objects.row import Row def test_add_cells(): row = Row(cells=[Cell(x1=0, x2=20, y1=0, y2=20), Cell(x1=20, x2=40, y1=0, y2=20)]) row.add_cells(cells=Cell(x1=40, x2=60, y1=0, y2=20)) assert row.nb_columns == 3 assert row.x2 ==
60
assert
numeric_literal
tests/tables/objects/test_row.py
test_add_cells
23
null
xavctn/img2table
from img2table.tables.objects.cell import Cell from img2table.tables.objects.line import Line from img2table.tables.processing.bordered_tables.tables.semi_bordered import get_lines_in_cluster, \ add_semi_bordered_cells, identify_table_dimensions, identify_potential_new_cells, update_cluster_cells def test_get_line...
[Line(x1=50, x2=205, y1=100, y2=100), Line(x1=50, x2=205, y1=200, y2=200)]
assert
collection
tests/tables/processing/bordered_tables/tables/test_semi_bordered.py
test_get_lines_in_cluster
18
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.processing.borderless_tables import identify_table from img2table.tables.processing.borderless_tables.model import ColumnGroup, Column, VerticalWS, Whitespace def test_identify_table(): with open("test_data/delimiter_group.json", "r"...
(91, 45, 1235, 1147)
assert
collection
tests/tables/processing/borderless_tables/table/test_table.py
test_identify_table
32
null
xavctn/img2table
import cv2 import numpy as np from sewar import ssim from img2table.document.base.rotation import rotate_img_with_border, fix_rotation_image, get_connected_components, \ get_relevant_angles, angle_dixon_q_test def test_get_connected_components(): img = cv2.imread("test_data/test.png", cv2.IMREAD_GRAYSCALE) ...
98
assert
numeric_literal
tests/document/base/test_rotation.py
test_get_connected_components
15
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.processing.borderless_tables.model import ColumnGroup, Column, VerticalWS, Whitespace from img2table.tables.processing.borderless_tables.rows import \ identify_delimiter_group_rows, identify_row_delimiters, filter_coherent_row_delimit...
18
assert
numeric_literal
tests/tables/processing/borderless_tables/rows/test_rows.py
test_identify_delimiter_group_rows
83
null
xavctn/img2table
import json import cv2 from img2table.tables import threshold_dark_areas from img2table.tables.objects.cell import Cell from img2table.tables.objects.line import Line from img2table.tables.processing.borderless_tables import identify_borderless_tables def test_identify_borderless_tables(): img = cv2.cvtColor(cv2...
7
assert
numeric_literal
tests/tables/processing/borderless_tables/borderless_tables/test_borderless_tables.py
test_identify_borderless_tables
32
null
xavctn/img2table
import json import cv2 from img2table.tables.objects.cell import Cell from img2table.tables.processing.borderless_tables.layout import get_image_elements def test_get_image_elements(): thresh = cv2.imread("test_data/text_thresh.bmp", cv2.IMREAD_GRAYSCALE) result = get_image_elements(thresh=thresh, ...
expected
assert
variable
tests/tables/processing/borderless_tables/layout/test_image_elements.py
test_get_image_elements
19
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.processing.borderless_tables.model import ColumnGroup, Column, VerticalWS, Whitespace from img2table.tables.processing.borderless_tables.rows import \ identify_delimiter_group_rows, identify_row_delimiters, filter_coherent_row_delimit...
1147
assert
numeric_literal
tests/tables/processing/borderless_tables/rows/test_rows.py
test_identify_delimiter_group_rows
85
null
xavctn/img2table
import cv2 from img2table.tables import threshold_dark_areas from img2table.tables.metrics import compute_char_length, compute_median_line_sep, compute_img_metrics def test_compute_char_length(): image = cv2.cvtColor(cv2.imread("test_data/test.png"), cv2.COLOR_BGR2RGB) thresh = threshold_dark_areas(img=image,...
(None, None, None)
assert
collection
tests/tables/image/test_metrics.py
test_compute_char_length
17
null
xavctn/img2table
import json from io import BytesIO from xlsxwriter import Workbook from img2table.tables.objects.cell import Cell from img2table.tables.objects.extraction import create_all_rectangles, CellPosition, TableCell, BBox, CellSpan from img2table.tables.objects.row import Row from img2table.tables.objects.table import Table...
table.nb_rows
assert
complex_expr
tests/tables/objects/test_extraction.py
test_extracted_table_worksheet
52
null
xavctn/img2table
import sys from io import BytesIO import pytest from img2table.document.pdf import PDF from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_load_pdf(): # Load from path pdf_from_path = PDF(src="test_data/test.pdf") # Load from bytes with open("test_dat...
(2200, 1700, 3)
assert
collection
tests/document/pdf/test_pdf.py
test_load_pdf
40
null
xavctn/img2table
import cv2 from img2table.tables.objects.cell import Cell from img2table.tables.processing.common import is_contained_cell, merge_contours, get_contours_cell def test_get_contours_cell(): img = cv2.cvtColor(cv2.imread("test_data/test.jpg"), cv2.COLOR_BGR2RGB) cell = Cell(x1=0, x2=img.shape[1], y1=0, y2=img.sh...
expected
assert
variable
tests/tables/processing/common/test_common.py
test_get_contours_cell
55
null
xavctn/img2table
import os import cv2 import polars as pl import pytest from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.ocr.data import OCRDataframe from tests import MOCK_DIR, TESSERACT_INSTALL def test_tesseract_ocr_df(mock_tesseract): instance = TesseractOCR() with open(os...
expected
assert
variable
tests/ocr/tesseract/test_tesseract.py
test_tesseract_ocr_df
66
null
xavctn/img2table
import json import cv2 from img2table.tables import threshold_dark_areas from img2table.tables.objects.cell import Cell from img2table.tables.objects.line import Line from img2table.tables.processing.borderless_tables import identify_borderless_tables def test_identify_borderless_tables(): img = cv2.cvtColor(cv2...
(135, 52, 1155, 1054)
assert
collection
tests/tables/processing/borderless_tables/borderless_tables/test_borderless_tables.py
test_identify_borderless_tables
33
null
xavctn/img2table
from io import BytesIO import pytest from openpyxl import load_workbook from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_image_excel(mock_tesseract): ocr = TesseractOCR() img = Image(src="test_data/test.png", ...
list(expected.worksheets[idx].values)
assert
func_call
tests/document/image/test_image.py
test_image_excel
107
null
xavctn/img2table
import json import polars as pl import pytest from img2table.document.image import Image from img2table.ocr.data import OCRDataframe from tests.conftest import nested_approx def test_paddle_content(): from img2table.ocr import PaddleOCR instance = PaddleOCR() doc = Image(src="test_data/test.png") r...
nested_approx(expected, abs=1e-3)
assert
func_call
tests/ocr/paddle/test_paddle.py
test_paddle_content
31
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.objects.line import Line from img2table.tables.objects.row import Row from img2table.tables.objects.table import Table from img2table.tables.processing.bordered_tables.tables import get_tables def test_get_tables(): with open("test_d...
expected
assert
variable
tests/tables/processing/bordered_tables/tables/test_tables.py
test_get_tables
26
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.objects.line import Line from img2table.tables.processing.borderless_tables.layout.column_segments import Rectangle, identify_remaining_segments, \ get_vertical_ws, is_column_section, identify_column_groups, get_column_group_segments,...
expected
assert
variable
tests/tables/processing/borderless_tables/layout/test_column_segments.py
test_identify_remaining_segments
26
null
xavctn/img2table
import json import os import pickle import polars as pl import pytest from img2table.document import Image from img2table.ocr.data import OCRDataframe from img2table.ocr.google_vision import VisionEndpointContent, VisionAPIContent, VisionOCR from tests import MOCK_DIR def test_vision_ocr(mock_vision): image = Im...
TypeError)
pytest.raises
variable
tests/ocr/google_vision/test_google_vision.py
test_vision_ocr
62
null
xavctn/img2table
import json from img2table.tables.objects.cell import Cell from img2table.tables.processing.borderless_tables.model import ColumnGroup, VerticalWS, Column, Whitespace from img2table.tables.processing.borderless_tables.table.table_creation import get_table def test_get_table(): with open("test_data/delimiter_group...
(91, 45, 1235, 1147)
assert
collection
tests/tables/processing/borderless_tables/table/test_table_creation.py
test_get_table
30
null
xavctn/img2table
import cv2 from img2table.tables.image import TableImage def test_table_image(): image = cv2.cvtColor(cv2.imread("test_data/test.png"), cv2.COLOR_BGR2RGB) tb_image = TableImage(img=image, min_confidence=50) result = tb_image.extract_tables(implicit_rows=True) result = sorte...
(6, 3)
assert
collection
tests/tables/image/test_image.py
test_table_image
18
null
xavctn/img2table
import json import os import pickle import polars as pl import pytest from img2table.document import Image from img2table.ocr.data import OCRDataframe from img2table.ocr.google_vision import VisionEndpointContent, VisionAPIContent, VisionOCR from tests import MOCK_DIR def test_vision_ocr(mock_vision): image = Im...
expected_ocr_df
assert
variable
tests/ocr/google_vision/test_google_vision.py
test_vision_ocr
72
null
xavctn/img2table
import json import polars as pl from img2table.ocr.data import OCRDataframe from img2table.tables.objects.cell import Cell from img2table.tables.objects.row import Row from img2table.tables.objects.table import Table def test_table(): with open("test_data/tables.json", "r") as f: tables = [Table(rows=[Ro...
6
assert
numeric_literal
tests/tables/objects/test_table.py
test_table
50
null
xavctn/img2table
import sys from io import BytesIO import pytest from img2table.document.pdf import PDF from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_pdf_tables(mock_tesseract): ocr = TesseractOCR() pdf = PDF(src="test_data/test.pdf") result = pdf.extract_tables(ocr...
"Example of Data Table 1"
assert
string_literal
tests/document/pdf/test_pdf.py
test_pdf_tables
54
null
xavctn/img2table
from img2table.tables.objects.cell import Cell from img2table.tables.objects.row import Row def test_row(): row = Row(cells=[Cell(x1=0, x2=20, y1=0, y2=20), Cell(x1=20, x2=40, y1=0, y2=20)]) assert row.x1 == 0 assert row.y1 == 0 assert row.x2 == 40 assert row.y2 == 20 assert row.nb_columns ==...
2
assert
numeric_literal
tests/tables/objects/test_row.py
test_row
13
null
xavctn/img2table
from io import BytesIO import pytest from openpyxl import load_workbook from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_image_tables(mock_tesseract): ocr = TesseractOCR() img = Image(src="test_data/test.png", ...
3
assert
numeric_literal
tests/document/image/test_image.py
test_image_tables
73
null
xavctn/img2table
import cv2 from img2table.tables.objects.cell import Cell from img2table.tables.processing.common import is_contained_cell, merge_contours, get_contours_cell def test_merge_contours(): contours = [Cell(x1=0, x2=20, y1=0, y2=20), Cell(x1=0, x2=20, y1=10, y2=20), Cell(x1=60, x2=80, y...
set(expected)
assert
func_call
tests/tables/processing/common/test_common.py
test_merge_contours
29
null
xavctn/img2table
import json from io import BytesIO from xlsxwriter import Workbook from img2table.tables.objects.cell import Cell from img2table.tables.objects.extraction import create_all_rectangles, CellPosition, TableCell, BBox, CellSpan from img2table.tables.objects.row import Row from img2table.tables.objects.table import Table...
table_values
assert
variable
tests/tables/objects/test_extraction.py
test_extracted_table_worksheet
58
null
xavctn/img2table
from io import BytesIO import pytest from openpyxl import load_workbook from img2table.document.image import Image from img2table.ocr import TesseractOCR from img2table.tables.objects.extraction import BBox def test_no_ocr(): img = Image(src="test_data/dark.png", detect_rotation=True) result...
19
assert
numeric_literal
tests/document/image/test_image.py
test_no_ocr
91
null
xavctn/img2table
import json import polars as pl from img2table.tables.objects.cell import Cell from img2table.tables.objects.line import Line from img2table.tables.processing.bordered_tables.cells.identification import get_cells_dataframe def test_get_cells_dataframe(): with open("test_data/lines.json", 'r') as f: data ...
sorted(expected, key=lambda c: (c.x1, c.y1, c.x2, c.y2))
assert
func_call
tests/tables/processing/bordered_tables/cells/test_identification_cells.py
test_get_cells_dataframe
24
null