File: utils.py

package info (click to toggle)
con-duct 0.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 584 kB
  • sloc: python: 4,324; sh: 22; makefile: 18
file content (26 lines) | stat: -rw-r--r-- 730 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
26
from __future__ import annotations
from io import BytesIO
from pathlib import Path


class MockStream:
    """Mocks stderr or stdout"""

    def __init__(self) -> None:
        self.buffer = BytesIO()

    def getvalue(self) -> bytes:
        return self.buffer.getvalue()


def assert_files(parent_dir: str, file_list: list[str], exists: bool = True) -> None:
    if exists:
        for file_path in file_list:
            assert Path(
                parent_dir, file_path
            ).exists(), f"Expected file does not exist: {file_path}"
    else:
        for file_path in file_list:
            assert not Path(
                parent_dir, file_path
            ).exists(), f"Unexpected file should not exist: {file_path}"