Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] extract build logic from the Command class #10075

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Refactor build command

7941c14
Select commit
Loading
Failed to load commit list.
Draft

[PoC] extract build logic from the Command class #10075

Refactor build command
7941c14
Select commit
Loading
Failed to load commit list.
Cirrus CI / Tests / FreeBSD (Python 3.11) / pytest failed Jan 18, 2025 in 2m 42s

Task Summary

Instruction pytest failed in 01:33

Details

✅ 00:03 clone
✅ 00:51 bootstrap_poetry
✅ 00:11 setup_environment
❌ 01:33 pytest

    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError
-------------- generated xml file: /tmp/cirrus-ci-build/junit.xml --------------
=========================== short test summary info ============================
SKIPPED [1] tests/integration/test_utils_vcs_git.py:316: HTTP authentication credentials not available
SKIPPED [1] tests/console/commands/test_run.py:88: Poetry only installs CMD script files for console scripts of editable dependencies on Windows
SKIPPED [1] tests/installation/test_executor.py:305: https://github.com/python-poetry/poetry/issues/7983
SKIPPED [1] tests/utils/env/test_env_manager.py:1299: requires darwin
SKIPPED [3] tests/console/commands/env/test_activate.py:52: Only Windows shells
SKIPPED [1] tests/utils/test_python_manager.py:98: Windows only
SKIPPED [1] tests/console/commands/self/test_sync.py:26: Only relevant for `poetry self install`
SKIPPED [1] tests/console/commands/test_sync.py:26: Only relevant for `poetry install`
FAILED tests/console/commands/test_build.py::test_build_output_option[absolute] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_clean_non_existing_output - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_multiple_readme_files - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_output_option[../dist] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_format_is_not_valid - AssertionError: Regex pattern did not match.
 Regex: 'Invalid format.*'
 Input: 'Invalid build format: not_valid'
FAILED tests/console/commands/test_build.py::test_build_with_local_version_label - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_output_option[dist] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_clean[True] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_output_option[None] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_relative_directory_src_layout - FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0/project/dist'
FAILED tests/console/commands/test_build.py::test_build_output_option[test/dir] - ValueError: Invalid build format: None
FAILED tests/console/commands/test_build.py::test_build_with_clean[False] - ValueError: Invalid build format: None
============ 12 failed, 2347 passed, 10 skipped in 91.45s (0:01:31) ============

Annotations

Check failure on line 183 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L183

tests.console.commands.test_build.test_build_output_option[absolute]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x77143095390>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_absol0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x771430e6b10>
output_dir = 'absolute'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
>           tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:183: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x771430e6b10>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_absol0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x77143095790>, format = None
clean = False, local_version_label = None
output = '/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_absol0/project/tmp/dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 114 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L114

tests.console.commands.test_build.test_build_with_clean_non_existing_output
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x7713f7bbf10>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_non_exis0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x77143043090>

    def test_build_with_clean_non_existing_output(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry
    ) -> None:
        dist_dir = tmp_project_path.joinpath("dist")
    
        remove_directory(dist_dir, force=True)
        assert not dist_dir.exists()
    
>       tmp_tester.execute("--clean")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:114: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x77143043090>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_non_exis0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x7713f7bb4d0>, format = None
clean = True, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 149 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L149

tests.console.commands.test_build.test_build_with_multiple_readme_files
Raw output
fixture_dir = <function fixture_dir.<locals>._fixture_dir at 0x77140bd4180>
tmp_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_multiple_readm0')
tmp_venv = VirtualEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_multiple_readm0/venv")
command_tester_factory = <function command_tester_factory.<locals>._tester at 0x77142f66980>

    def test_build_with_multiple_readme_files(
        fixture_dir: FixtureDirGetter,
        tmp_path: Path,
        tmp_venv: VirtualEnv,
        command_tester_factory: CommandTesterFactory,
    ) -> None:
        source_dir = fixture_dir("with_multiple_readme_files")
        target_dir = tmp_path / "project"
        shutil.copytree(str(source_dir), str(target_dir))
    
        poetry = Factory().create_poetry(target_dir)
        tester = command_tester_factory("build", poetry, environment=tmp_venv)
>       tester.execute()

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x771430f2450>
env = VirtualEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_multiple_readm0/venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x771430d5a50>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 186 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L186

tests.console.commands.test_build.test_build_output_option[../dist]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x77142d97150>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option____di0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x771431f1ad0>
output_dir = '../dist'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
            tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")
            build_dir = tmp_project_path / "tmp/dist"
        else:
>           tmp_tester.execute(f"--output {output_dir}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x771431f1ad0>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option____di0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x77142d94210>, format = None
clean = False, local_version_label = None, output = '../dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 60 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L60

tests.console.commands.test_build.test_build_format_is_not_valid
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x77142d87950>

    def test_build_format_is_not_valid(tmp_tester: CommandTester) -> None:
        with pytest.raises(ValueError, match=r"Invalid format.*"):
>           tmp_tester.execute("--format not_valid")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:60: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x7713f7db850>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_format_is_not_valid0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x77142d87210>
format = 'not_valid', clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: not_valid

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

During handling of the above exception, another exception occurred:

tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x77142d87950>

    def test_build_format_is_not_valid(tmp_tester: CommandTester) -> None:
>       with pytest.raises(ValueError, match=r"Invalid format.*"):
E       AssertionError: Regex pattern did not match.
E        Regex: 'Invalid format.*'
E        Input: 'Invalid build format: not_valid'

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:59: AssertionError

Check failure on line 81 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L81

tests.console.commands.test_build.test_build_with_local_version_label
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x77141527410>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_local_version_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x77142f4f8d0>

    def test_build_with_local_version_label(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        local_version_label = "local-version"
>       tmp_tester.execute(f"--local-version {local_version_label}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x77142f4f8d0>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_local_version_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x77141526610>, format = None
clean = False, local_version_label = 'local-version', output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 186 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L186

tests.console.commands.test_build.test_build_output_option[dist]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x77142ffdb90>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_dist_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x771416a81d0>, output_dir = 'dist'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
            tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")
            build_dir = tmp_project_path / "tmp/dist"
        else:
>           tmp_tester.execute(f"--output {output_dir}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x771416a81d0>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_dist_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x77142ffde10>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 99 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L99

tests.console.commands.test_build.test_build_with_clean[True]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x77142cd3d10>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_True_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x77142f71b50>, clean = True

    @pytest.mark.parametrize("clean", [True, False])
    def test_build_with_clean(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry, clean: bool
    ) -> None:
        dist_dir = tmp_project_path.joinpath("dist")
        dist_dir.joinpath("hello").touch(exist_ok=True)
    
>       tmp_tester.execute("--clean" if clean else "")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x77142f71b50>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_True_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x77142cd0dd0>, format = None
clean = True, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 180 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L180

tests.console.commands.test_build.test_build_output_option[None]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x7713e873a50>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_None_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x7713f5cff10>, output_dir = None

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
>           tmp_tester.execute()

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x7713f5cff10>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_None_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x7713fa3f590>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 213 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L213

tests.console.commands.test_build.test_build_relative_directory_src_layout
Raw output
tmp_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0')
fixture_dir = <function fixture_dir.<locals>._fixture_dir at 0x77140bd4180>

    def test_build_relative_directory_src_layout(
        tmp_path: Path, fixture_dir: FixtureDirGetter
    ) -> None:
        tmp_project_path = tmp_path / "project"
        with with_working_directory(fixture_dir("simple_project"), tmp_project_path):
            shutil.rmtree(tmp_project_path / "dist")
            (tmp_project_path / "src").mkdir()
            (tmp_project_path / "simple_project").rename(
                tmp_project_path / "src" / "simple_project"
            )
    
            # We have to use ApplicationTester because CommandTester
            # initializes Poetry before passing the directory.
            app = Application()
            tester = ApplicationTester(app)
            tester.execute("build --project .")
    
            build_dir = tmp_project_path / "dist"
    
>           assert len(list(build_dir.iterdir())) == 2

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:213: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0/project/dist')

    def iterdir(self):
        """Iterate over the files in this directory.  Does not yield any
        result for the special paths '.' and '..'.
        """
>       for name in os.listdir(self):
E       FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_relative_directory_0/project/dist'

/usr/local/lib/python3.11/pathlib.py:931: FileNotFoundError

Check failure on line 186 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L186

tests.console.commands.test_build.test_build_output_option[test/dir]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x7713f4eb710>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_test_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x77142d5ae50>
output_dir = 'test/dir'

    @pytest.mark.parametrize(
        "output_dir", [None, "dist", "test/dir", "../dist", "absolute"]
    )
    def test_build_output_option(
        tmp_tester: CommandTester,
        tmp_project_path: Path,
        tmp_poetry: Poetry,
        output_dir: str,
    ) -> None:
        shutil.rmtree(tmp_project_path / "dist")
        if output_dir is None:
            tmp_tester.execute()
            build_dir = tmp_project_path / "dist"
        elif output_dir == "absolute":
            tmp_tester.execute(f"--output {tmp_project_path / 'tmp/dist'}")
            build_dir = tmp_project_path / "tmp/dist"
        else:
>           tmp_tester.execute(f"--output {output_dir}")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x77142d5ae50>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_output_option_test_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x771416d40d0>, format = None
clean = False, local_version_label = None, output = 'test/dir'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError

Check failure on line 99 in tests/console/commands/test_build.py

See this annotation in the file changed.

@cirrus-ci cirrus-ci / Tests / FreeBSD (Python 3.11) / pytest

tests/console/commands/test_build.py#L99

tests.console.commands.test_build.test_build_with_clean[False]
Raw output
tmp_tester = <cleo.testers.command_tester.CommandTester object at 0x7713cdbb610>
tmp_project_path = PosixPath('/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_False_0/project')
tmp_poetry = <poetry.poetry.Poetry object at 0x7714153e310>, clean = False

    @pytest.mark.parametrize("clean", [True, False])
    def test_build_with_clean(
        tmp_tester: CommandTester, tmp_project_path: Path, tmp_poetry: Poetry, clean: bool
    ) -> None:
        dist_dir = tmp_project_path.joinpath("dist")
        dist_dir.joinpath("hello").touch(exist_ok=True)
    
>       tmp_tester.execute("--clean" if clean else "")

/tmp/cirrus-ci-build/tests/console/commands/test_build.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/testers/command_tester.py:88: in execute
    self._status_code = self._command.run(self._io)
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117: in run
    return self.execute(io) or 0
/.cache/pypoetry/virtualenvs/poetry-XZqP7kBn-py3.11/lib/python3.11/site-packages/cleo/commands/command.py:61: in execute
    return self.handle()
/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:55: in handle
    return self.build(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

poetry = <poetry.poetry.Poetry object at 0x7714153e310>
env = MockEnv("/tmp/pytest-of-root/pytest-0/popen-gw0/test_build_with_clean_False_0/.venv")
io = <cleo.io.buffered_io.BufferedIO object at 0x77141671ed0>, format = None
clean = False, local_version_label = None, output = 'dist'

    @staticmethod
    def build(
        poetry: Poetry,
        env: Env,
        io: IO,
        format: str = "all",
        clean: bool = True,
        local_version_label: str | None = None,
        output: str = "dist",
    ) -> int:
        from poetry.masonry.builders import BUILD_FORMATS
    
        if not poetry.is_package_mode:
            io.write_error_line(
                "Building a package is not possible in non-package mode."
            )
            return 1
    
        with build_environment(poetry=poetry, env=env, io=io) as env:
            dist_dir = Path(output)
            package = poetry.package
            io.write_line(
                f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)"
            )
    
            if not dist_dir.is_absolute():
                dist_dir = poetry.pyproject_path.parent / dist_dir
    
            if clean:
                remove_directory(path=dist_dir, force=True)
    
            if format in BUILD_FORMATS:
                builders = [BUILD_FORMATS[format]]
            elif format == "all":
                builders = list(BUILD_FORMATS.values())
            else:
>               raise ValueError(f"Invalid build format: {format}")
E               ValueError: Invalid build format: None

/tmp/cirrus-ci-build/src/poetry/console/commands/build.py:101: ValueError