Debian Codegraph @

tests/unit/test_condatools.py

raw
1 from __future__ import annotations
2
3 import re
4 from pathlib import Path
5 from unittest.mock import patch
6
7 import pytest
8
9 from auditwheel.condatools import InCondaPkg, InCondaPkgCtx
10
11
12 @patch("auditwheel.condatools.tarbz2todir")
13 def test_in_condapkg(_): # noqa: PT019
14 with InCondaPkg(Path("/fakepath")):
15 assert True
16
17
18 @patch("auditwheel.condatools.tarbz2todir")
19 def test_in_condapkg_context(_): # noqa: PT019
20 with InCondaPkgCtx(Path("/fakepath")) as conda_pkg:
21 # mock info/files
22 files_path = conda_pkg.path / "info" / "files"
23 files_path.parent.mkdir()
24 files_path.write_text("file1\nfile2\n\n")
25 # This returns empty lines so we have count with those as well. This
26 # might be a subtle bug in the implementation.
27 files = conda_pkg.iter_files()
28 assert len(files) == 3
29 assert "file1" in files
30 assert "file2" in files
31
32
33 @patch("auditwheel.condatools.tarbz2todir")
34 def test_in_condapkg_context_no_manager(_): # noqa: PT019
35 conda_pkg = InCondaPkgCtx(Path("/fakepath"))
36 with pytest.raises(
37 ValueError,
38 match=re.escape("This function should be called from context manager"),
39 ):
40 conda_pkg.iter_files()