File: test_condatools.py

package info (click to toggle)
python-auditwheel 5.3.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 816 kB
  • sloc: python: 4,270; ansic: 205; cpp: 58; makefile: 20; f90: 12
file content (23 lines) | stat: -rw-r--r-- 842 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
from unittest.mock import Mock, patch

from auditwheel.condatools import InCondaPkg, InCondaPkgCtx


@patch("auditwheel.condatools.tarbz2todir")
def test_in_condapkg(tarbz2todir_mock):
    with InCondaPkg("/fakepath"):
        assert True


@patch("auditwheel.condatools.tarbz2todir")
@patch("auditwheel.condatools.open")
def test_in_condapkg_context(open_mock, tarbz2todir_mock):
    with InCondaPkgCtx("/fakepath") as conda_pkg:
        file_mock = Mock()
        file_mock.readlines.return_value = ["file1\n", "file2\n", "\n"]
        open_mock.return_value.__enter__.return_value = file_mock
        # 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" and "file2" in files