Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
25767bcb
Commit
25767bcb
authored
Oct 31, 2022
by
Donato Quartuccia
Committed by
Mathieu Kniewallner
Nov 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add coverage to `poetry install`
parent
28b0b1dc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
tests/console/commands/test_install.py
+96
-0
No files found.
tests/console/commands/test_install.py
View file @
25767bcb
...
@@ -169,6 +169,17 @@ def test_all_extras_populates_installer(tester: CommandTester, mocker: MockerFix
...
@@ -169,6 +169,17 @@ def test_all_extras_populates_installer(tester: CommandTester, mocker: MockerFix
assert
tester
.
command
.
installer
.
_extras
==
[
"extras-a"
,
"extras-b"
]
assert
tester
.
command
.
installer
.
_extras
==
[
"extras-a"
,
"extras-b"
]
def
test_extras_are_parsed_and_populate_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
,
):
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
tester
.
execute
(
'--extras "first second third"'
)
assert
tester
.
command
.
installer
.
_extras
==
[
"first"
,
"second"
,
"third"
]
def
test_extras_conflicts_all_extras
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_extras_conflicts_all_extras
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
"""
"""
The --extras doesn't make sense with --all-extras.
The --extras doesn't make sense with --all-extras.
...
@@ -185,6 +196,48 @@ def test_extras_conflicts_all_extras(tester: CommandTester, mocker: MockerFixtur
...
@@ -185,6 +196,48 @@ def test_extras_conflicts_all_extras(tester: CommandTester, mocker: MockerFixtur
)
)
@pytest.mark.parametrize
(
"options"
,
[
"--with foo"
,
"--without foo"
,
"--with foo,bar --without baz"
,
"--only foo"
,
],
)
def
test_only_root_conflicts_with_without_only
(
options
:
str
,
tester
:
CommandTester
,
mocker
:
MockerFixture
,
):
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
tester
.
execute
(
f
"{options} --only-root"
)
assert
tester
.
status_code
==
1
assert
(
tester
.
io
.
fetch_error
()
==
"The `--with`, `--without` and `--only` options cannot be used with"
" the `--only-root` option.
\n
"
)
def
test_remove_untracked_outputs_deprecation_warning
(
tester
:
CommandTester
,
mocker
:
MockerFixture
,
):
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
tester
.
execute
(
"--remove-untracked"
)
assert
tester
.
status_code
==
0
assert
(
tester
.
io
.
fetch_error
()
==
"The `--remove-untracked` option is deprecated, use the `--sync` option"
" instead.
\n
"
)
def
test_dry_run_populates_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
def
test_dry_run_populates_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
"""
"""
The --dry-run option results in extras passed to the installer.
The --dry-run option results in extras passed to the installer.
...
@@ -195,3 +248,46 @@ def test_dry_run_populates_installer(tester: CommandTester, mocker: MockerFixtur
...
@@ -195,3 +248,46 @@ def test_dry_run_populates_installer(tester: CommandTester, mocker: MockerFixtur
tester
.
execute
(
"--dry-run"
)
tester
.
execute
(
"--dry-run"
)
assert
tester
.
command
.
installer
.
_dry_run
is
True
assert
tester
.
command
.
installer
.
_dry_run
is
True
def
test_dry_run_does_not_build
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocked_editable_builder
=
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
)
tester
.
execute
(
"--dry-run"
)
assert
mocked_editable_builder
.
return_value
.
build
.
call_count
==
0
def
test_install_logs_output
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
)
tester
.
execute
()
assert
tester
.
status_code
==
0
assert
(
tester
.
io
.
fetch_output
()
==
"
\n
Installing the current project: simple-project (1.2.3)
\n
"
)
def
test_install_logs_output_decorated
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
mocker
.
patch
(
"poetry.masonry.builders.editable.EditableBuilder"
)
tester
.
execute
(
decorated
=
True
)
expected
=
(
"
\n
"
"
\x1b
[39;1mInstalling
\x1b
[39;22m the current project: "
"
\x1b
[36msimple-project
\x1b
[39m (
\x1b
[39;1m1.2.3
\x1b
[39;22m)"
"
\x1b
[1G
\x1b
[2K"
"
\x1b
[39;1mInstalling
\x1b
[39;22m the current project: "
"
\x1b
[36msimple-project
\x1b
[39m (
\x1b
[32m1.2.3
\x1b
[39m)"
"
\n
"
)
assert
tester
.
status_code
==
0
assert
tester
.
io
.
fetch_output
()
==
expected
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment