mirror of
https://github.com/opendatalab/MinerU.git
synced 2026-10-30 19:33:43 +08:00
add cli test
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
import os
|
||||
conf = {
|
||||
"code_path": os.environ.get('CI_PROJECT_DIR'),
|
||||
"pdf_dev_path" : os.environ.get('CI_PROJECT_DIR') + "/tests/pdf_dev",
|
||||
"pdf_res_path": "/home/quyuan/code/Magic-PDF/Magic-PDF/Magic-PDF/data"
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import subprocess
|
||||
def check_shell(cmd):
|
||||
res = subprocess.check_output(cmd, shell=True)
|
||||
assert res == 0
|
||||
|
||||
def count_folders_and_check_contents(directory):
|
||||
# 获取目录下的所有文件和文件夹
|
||||
contents = os.listdir(directory)
|
||||
folder_count = 0
|
||||
for item in contents:
|
||||
# 检查是否为文件夹
|
||||
if os.path.isdir(os.path.join(directory, item)):
|
||||
folder_count += 1
|
||||
# 检查文件夹是否为空
|
||||
folder_path = os.path.join(directory, item)
|
||||
assert os.listdir(folder_path) is not None
|
||||
assert folder_count == 3
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -1,31 +0,0 @@
|
||||
import pytest
|
||||
import os
|
||||
from conf import conf
|
||||
import subprocess
|
||||
from lib import common
|
||||
import logging
|
||||
pdf_res_path = conf.conf["pdf_res_path"]
|
||||
code_path = conf.conf["code_path"]
|
||||
pdf_dev_path = conf.conf["pdf_dev_path"]
|
||||
class TestCli:
|
||||
|
||||
def test_pdf_specify_dir(self):
|
||||
"""
|
||||
输入pdf和指定目录的模型结果
|
||||
"""
|
||||
cmd = 'cd %s && export PYTHONPATH=. && find %s -type f -name "*.pdf" | xargs -I{} python magic_pdf/cli/magicpdf.py pdf-command --pdf {}' % (code_path, pdf_dev_path)
|
||||
logging.info(cmd)
|
||||
common.check_shell(cmd)
|
||||
common.count_folders_and_check_contents(pdf_res_path)
|
||||
|
||||
|
||||
def test_pdf_specify_jsonl(self):
|
||||
"""
|
||||
输入jsonl
|
||||
"""
|
||||
cmd = "cd %s && export PYTHONPATH=. && python "
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main()
|
||||
Reference in New Issue
Block a user