File: conftest.py

package info (click to toggle)
pytaglib 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,136 kB
  • sloc: python: 429; makefile: 7
file content (34 lines) | stat: -rw-r--r-- 828 bytes parent folder | download
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
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
# Copyright 2019 Michael Helmling
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation
#

import shutil
from pathlib import Path

import pytest
import taglib


@pytest.fixture
def test_data(tmp_path):
    def result(filename):
        """Make a temporary copy of test data file *name* (without dir) and return its full path."""
        source = Path(__file__).parent / "data" / filename
        target = tmp_path / filename
        shutil.copyfile(source, target)
        return target

    return result


@pytest.fixture
def test_file(test_data):
    def result(filename):
        data_file = test_data(filename)
        return taglib.File(data_file)

    return result