コード例 #1
0
    def test_build_wheel_fails_with_no_setup_file(tmp_path):
        with pytest.raises(RuntimeError) as excinfo:
            pdu._build_wheel(tmp_path.as_posix())

        assert excinfo.value.message == (
            'No setup.py file exists in directory '
            '{}'.format(tmp_path.as_posix()))
コード例 #2
0
    def test_build_wheel(mock_popen, tmp_path):
        setup_file = tmp_path / 'setup.py'
        setup_file.touch()

        mock_popen.return_value.communicate.return_value = ('output', '')
        mock_popen.return_value.wait.return_value = 0

        pdu._build_wheel(tmp_path.as_posix())

        mock_popen.assert_called_once_with(
            [sys.executable, 'setup.py', 'bdist_wheel'],
            cwd=tmp_path.as_posix(),
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT)
コード例 #3
0
    def test_build_wheel_non_zero_exit(mock_popen, tmp_path):
        setup_file = tmp_path / 'setup.py'
        setup_file.touch()

        mock_popen.return_value.communicate.return_value = ('output', '')
        mock_popen.return_value.wait.return_value = 1

        with pytest.raises(SubprocessFailedError) as excinfo:
            pdu._build_wheel(tmp_path.as_posix())

        e = excinfo.value

        expected_args = [sys.executable, 'setup.py', 'bdist_wheel']
        mock_popen.asesrt_called_once_with(expected_args,
                                           cwd=tmp_path.as_posix(),
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.STDOUT)

        assert e.command == ' '.join(expected_args)
        assert e.exit_code == 1
        assert e.output == 'output'
コード例 #4
0
    def test_build_wheel_target_dir(mock_popen, tmp_path):
        package_dir = tmp_path / 'pkg'
        setup_file = package_dir / 'setup.py'
        target_dir = tmp_path / 'tgt'
        package_dir.mkdir()
        setup_file.touch()
        target_dir.mkdir()

        mock_popen.return_value.communicate.return_value = ('output', '')
        mock_popen.return_value.wait.return_value = 0

        pdu._build_wheel(package_dir.as_posix(),
                         target_dir=target_dir.as_posix())

        expected_args = [
            sys.executable, 'setup.py', 'bdist_wheel', '-d',
            target_dir.as_posix()
        ]
        mock_popen.assert_called_once_with(expected_args,
                                           cwd=package_dir.as_posix(),
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.STDOUT)