Files
photo-dater/pytest/fixtures.py

44 lines
951 B
Python

import os
import pytest
from helpers import *
log_file_name = 'example.log'
@pytest.fixture(autouse=True)
def cleanup_logs():
if os.path.exists(log_file_name):
os.remove(log_file_name)
yield
if os.path.exists(log_file_name):
os.remove(log_file_name)
@pytest.fixture
def tmp_dir():
tmp_dir_name = gen_rand_name(12)
tmp_dir_path = os.path.join("/tmp/photosorter/", tmp_dir_name)
os.makedirs(tmp_dir_path, exist_ok=True)
return tmp_dir_path
@pytest.fixture
def log_file():
return log_file_name
@pytest.fixture
def in_out_dirs(tmp_dir):
in_dir_name = gen_rand_name(12)
out_dir_name = gen_rand_name(12)
while out_dir_name == in_dir_name:
out_dir_name = gen_rand_name(12)
in_dir_path = os.path.join(tmp_dir, in_dir_name)
out_dir_path = os.path.join(tmp_dir, out_dir_name)
os.mkdir(in_dir_path)
os.mkdir(out_dir_path)
return (in_dir_path, out_dir_path)