File: conftest.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (25 lines) | stat: -rw-r--r-- 681 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pytest
import tempfile
import os

from typing import List
from tempfile import TemporaryDirectory


@pytest.fixture()
def tmp_directory_create():
    with TemporaryDirectory() as tmp_dir:

        def create_temp_directory(fake_creation_paths: List[str]) -> TemporaryDirectory:
            for file in fake_creation_paths:
                target_path = os.path.join(tmp_dir, file)
                dirname = os.path.join(tmp_dir, os.path.dirname(file))

                if not os.path.exists(dirname):
                    os.mkdir(dirname)

                with open(target_path, "w"):
                    pass
            return tmp_dir

        yield create_temp_directory