File: test_condatools.py

package info (click to toggle)
python-auditwheel 6.6.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 980 kB
  • sloc: python: 6,165; ansic: 304; cpp: 66; sh: 28; makefile: 25; f90: 12
file content (40 lines) | stat: -rw-r--r-- 1,222 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
35
36
37
38
39
40
from __future__ import annotations

import re
from pathlib import Path
from unittest.mock import patch

import pytest

from auditwheel.condatools import InCondaPkg, InCondaPkgCtx


@patch("auditwheel.condatools.tarbz2todir")
def test_in_condapkg(_):  # noqa: PT019
    with InCondaPkg(Path("/fakepath")):
        assert True


@patch("auditwheel.condatools.tarbz2todir")
def test_in_condapkg_context(_):  # noqa: PT019
    with InCondaPkgCtx(Path("/fakepath")) as conda_pkg:
        # mock info/files
        files_path = conda_pkg.path / "info" / "files"
        files_path.parent.mkdir()
        files_path.write_text("file1\nfile2\n\n")
        # This returns empty lines so we have count with those as well. This
        # might be a subtle bug in the implementation.
        files = conda_pkg.iter_files()
        assert len(files) == 3
        assert "file1" in files
        assert "file2" in files


@patch("auditwheel.condatools.tarbz2todir")
def test_in_condapkg_context_no_manager(_):  # noqa: PT019
    conda_pkg = InCondaPkgCtx(Path("/fakepath"))
    with pytest.raises(
        ValueError,
        match=re.escape("This function should be called from context manager"),
    ):
        conda_pkg.iter_files()