1
0
Fork 0
mirror of https://github.com/qurator-spk/dinglehopper.git synced 2025-06-09 03:40:12 +02:00

🎨 dinglehopper: Move working_directory() context manager into tests/util

This commit is contained in:
Gerber, Mike 2019-12-02 15:18:08 +01:00
parent f98c527c93
commit 5ccdace1dd
3 changed files with 16 additions and 26 deletions

View file

@ -2,23 +2,11 @@ import os
import json
import pytest
from .util import working_directory
from ..cli import process
class working_directory:
"""Context manager to temporarily change the working directory"""
def __init__(self, wd):
self.wd = wd
def __enter__(self):
self.old_wd = os.getcwd()
os.chdir(self.wd)
def __exit__(self, etype, value, traceback):
os.chdir(self.old_wd)
def test_cli_json(tmp_path):
"""Test that the cli/process() yields a loadable JSON report"""

View file

@ -6,6 +6,7 @@ from pathlib import Path
from click.testing import CliRunner
import pytest
from .util import working_directory
from ..ocrd_cli import ocrd_dinglehopper
@ -13,19 +14,6 @@ from ..ocrd_cli import ocrd_dinglehopper
data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
class working_directory:
"""Context manager to temporarily change the working directory"""
def __init__(self, wd):
self.wd = wd
def __enter__(self):
self.old_wd = os.getcwd()
os.chdir(self.wd)
def __exit__(self, etype, value, traceback):
os.chdir(self.old_wd)
def test_ocrd_cli(tmp_path):
"""Test OCR-D interface"""

View file

@ -2,6 +2,7 @@ from itertools import zip_longest
from typing import Iterable
import colorama
import os
def diffprint(x, y):
@ -22,3 +23,16 @@ def diffprint(x, y):
def unzip(l):
return zip(*l)
class working_directory:
"""Context manager to temporarily change the working directory"""
def __init__(self, wd):
self.wd = wd
def __enter__(self):
self.old_wd = os.getcwd()
os.chdir(self.wd)
def __exit__(self, etype, value, traceback):
os.chdir(self.old_wd)