PHP 8.2.30
Preview: test_install_data.py Size: 2.41 KB
//opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_distutils/tests/test_install_data.py

"""Tests for distutils.command.install_data."""

import os
import pathlib
from distutils.command.install_data import install_data
from distutils.tests import support

import pytest


@pytest.mark.usefixtures('save_env')
class TestInstallData(
    support.TempdirManager,
):
    def test_simple_run(self):
        pkg_dir, dist = self.create_dist()
        cmd = install_data(dist)
        cmd.install_dir = inst = os.path.join(pkg_dir, 'inst')

        # data_files can contain
        #  - simple files
        #  - a Path object
        #  - a tuple with a path, and a list of file
        one = os.path.join(pkg_dir, 'one')
        self.write_file(one, 'xxx')
        inst2 = os.path.join(pkg_dir, 'inst2')
        two = os.path.join(pkg_dir, 'two')
        self.write_file(two, 'xxx')
        three = pathlib.Path(pkg_dir) / 'three'
        self.write_file(three, 'xxx')

        cmd.data_files = [one, (inst2, [two]), three]
        assert cmd.get_inputs() == [one, (inst2, [two]), three]

        # let's run the command
        cmd.ensure_finalized()
        cmd.run()

        # let's check the result
        assert len(cmd.get_outputs()) == 3
        rthree = os.path.split(one)[-1]
        assert os.path.exists(os.path.join(inst, rthree))
        rtwo = os.path.split(two)[-1]
        assert os.path.exists(os.path.join(inst2, rtwo))
        rone = os.path.split(one)[-1]
        assert os.path.exists(os.path.join(inst, rone))
        cmd.outfiles = []

        # let's try with warn_dir one
        cmd.warn_dir = True
        cmd.ensure_finalized()
        cmd.run()

        # let's check the result
        assert len(cmd.get_outputs()) == 3
        assert os.path.exists(os.path.join(inst, rthree))
        assert os.path.exists(os.path.join(inst2, rtwo))
        assert os.path.exists(os.path.join(inst, rone))
        cmd.outfiles = []

        # now using root and empty dir
        cmd.root = os.path.join(pkg_dir, 'root')
        inst5 = os.path.join(pkg_dir, 'inst5')
        four = os.path.join(cmd.install_dir, 'four')
        self.write_file(four, 'xx')
        cmd.data_files = [one, (inst2, [two]), three, ('inst5', [four]), (inst5, [])]
        cmd.ensure_finalized()
        cmd.run()

        # let's check the result
        assert len(cmd.get_outputs()) == 5
        assert os.path.exists(os.path.join(inst, rthree))
        assert os.path.exists(os.path.join(inst2, rtwo))
        assert os.path.exists(os.path.join(inst, rone))

Directory Contents

Dirs: 2 × Files: 36

Name Size Perms Modified Actions
compat DIR
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
4.00 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
11.51 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.36 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
2.19 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.84 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.70 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
4.23 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
22.02 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
6.72 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
2.81 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
6.08 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.21 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.18 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
2.60 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.74 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
4.39 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
18.35 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.58 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
10.51 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.44 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
8.42 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
2.41 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
936 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.53 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.56 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
323 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
4.12 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
14.71 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
4.69 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
11.71 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
3.38 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
7.80 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
2.69 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download
0 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
386 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
1.45 KB lrw-r--r-- 2026-01-20 13:01:47
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).