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
d18b6520
Commit
d18b6520
authored
Apr 05, 2022
by
Arun Babu Neelicattu
Committed by
Randy Döring
Apr 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: load plugins when for command tester
This change cleans up loading of plugins when testing commands.
parent
3ccd8fd8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
65 deletions
+66
-65
src/poetry/console/application.py
+5
-1
tests/conftest.py
+0
-63
tests/console/conftest.py
+61
-1
No files found.
src/poetry/console/application.py
View file @
d18b6520
...
...
@@ -16,6 +16,7 @@ from cleo.events.event_dispatcher import EventDispatcher
from
cleo.exceptions
import
CleoException
from
cleo.formatters.style
import
Style
from
cleo.io.inputs.argv_input
import
ArgvInput
from
cleo.io.null_io
import
NullIO
from
poetry.__version__
import
__version__
from
poetry.console.command_loader
import
CommandLoader
...
...
@@ -306,10 +307,13 @@ class Application(BaseApplication):
installer
.
use_executor
(
poetry
.
config
.
get
(
"experimental.new-installer"
,
False
))
command
.
set_installer
(
installer
)
def
_load_plugins
(
self
,
io
:
IO
)
->
None
:
def
_load_plugins
(
self
,
io
:
IO
=
None
)
->
None
:
if
self
.
_plugins_loaded
:
return
if
io
is
None
:
io
=
NullIO
()
self
.
_disable_plugins
=
io
.
input
.
has_parameter_option
(
"--no-plugins"
)
if
not
self
.
_disable_plugins
:
...
...
tests/conftest.py
View file @
d18b6520
...
...
@@ -16,7 +16,6 @@ from typing import TextIO
import
httpretty
import
pytest
from
cleo.testers.command_tester
import
CommandTester
from
keyring.backend
import
KeyringBackend
from
poetry.config.config
import
Config
as
BaseConfig
...
...
@@ -24,14 +23,12 @@ from poetry.config.dict_config_source import DictConfigSource
from
poetry.factory
import
Factory
from
poetry.inspection.info
import
PackageInfo
from
poetry.inspection.info
import
PackageInfoError
from
poetry.installation
import
Installer
from
poetry.layouts
import
layout
from
poetry.repositories
import
Pool
from
poetry.repositories
import
Repository
from
poetry.utils.env
import
EnvManager
from
poetry.utils.env
import
SystemEnv
from
poetry.utils.env
import
VirtualEnv
from
tests.helpers
import
TestExecutor
from
tests.helpers
import
TestLocker
from
tests.helpers
import
TestRepository
from
tests.helpers
import
get_package
...
...
@@ -42,12 +39,7 @@ from tests.helpers import mock_download
if
TYPE_CHECKING
:
from
pytest_mock
import
MockerFixture
from
poetry.installation.executor
import
Executor
from
poetry.poetry
import
Poetry
from
poetry.utils.env
import
Env
from
poetry.utils.env
import
MockEnv
from
tests.helpers
import
PoetryTestApplication
from
tests.types
import
CommandTesterFactory
from
tests.types
import
FixtureDirGetter
from
tests.types
import
ProjectFactory
...
...
@@ -406,60 +398,5 @@ def project_factory(
@pytest.fixture
def
command_tester_factory
(
app
:
PoetryTestApplication
,
env
:
MockEnv
)
->
CommandTesterFactory
:
def
_tester
(
command
:
str
,
poetry
:
Poetry
|
None
=
None
,
installer
:
Installer
|
None
=
None
,
executor
:
Executor
|
None
=
None
,
environment
:
Env
|
None
=
None
,
)
->
CommandTester
:
command
=
app
.
find
(
command
)
tester
=
CommandTester
(
command
)
# Setting the formatter from the application
# TODO: Find a better way to do this in Cleo
app_io
=
app
.
create_io
()
formatter
=
app_io
.
output
.
formatter
tester
.
io
.
output
.
set_formatter
(
formatter
)
tester
.
io
.
error_output
.
set_formatter
(
formatter
)
if
poetry
:
app
.
_poetry
=
poetry
poetry
=
app
.
poetry
command
.
_pool
=
poetry
.
pool
if
hasattr
(
command
,
"set_env"
):
command
.
set_env
(
environment
or
env
)
if
hasattr
(
command
,
"set_installer"
):
installer
=
installer
or
Installer
(
tester
.
io
,
env
,
poetry
.
package
,
poetry
.
locker
,
poetry
.
pool
,
poetry
.
config
,
executor
=
executor
or
TestExecutor
(
env
,
poetry
.
pool
,
poetry
.
config
,
tester
.
io
),
)
installer
.
use_executor
(
True
)
command
.
set_installer
(
installer
)
return
tester
return
_tester
@pytest.fixture
def
do_lock
(
command_tester_factory
:
CommandTesterFactory
,
poetry
:
Poetry
)
->
None
:
command_tester_factory
(
"lock"
)
.
execute
()
assert
poetry
.
locker
.
lock
.
exists
()
@pytest.fixture
def
project_root
()
->
Path
:
return
Path
(
__file__
)
.
parent
.
parent
tests/console/conftest.py
View file @
d18b6520
...
...
@@ -10,8 +10,10 @@ import pytest
from
cleo.io.null_io
import
NullIO
from
cleo.testers.application_tester
import
ApplicationTester
from
cleo.testers.command_tester
import
CommandTester
from
poetry.factory
import
Factory
from
poetry.installation
import
Installer
from
poetry.installation.noop_installer
import
NoopInstaller
from
poetry.repositories
import
Pool
from
poetry.utils.env
import
MockEnv
...
...
@@ -24,10 +26,13 @@ from tests.helpers import mock_clone
if
TYPE_CHECKING
:
from
pytest_mock
import
MockerFixture
from
poetry.installation.executor
import
Executor
from
poetry.poetry
import
Poetry
from
poetry.repositories
import
Repository
from
poetry.utils.env
import
Env
from
tests.conftest
import
Config
from
tests.helpers
import
TestRepository
from
tests.types
import
CommandTesterFactory
@pytest.fixture
()
...
...
@@ -117,7 +122,7 @@ def poetry(repo: TestRepository, project_directory: str, config: Config) -> Poet
@pytest.fixture
def
app
(
poetry
:
Poetry
)
->
PoetryTestApplication
:
app_
=
PoetryTestApplication
(
poetry
)
app_
.
_load_plugins
()
return
app_
...
...
@@ -134,3 +139,58 @@ def new_installer_disabled(config: Config) -> None:
@pytest.fixture
()
def
executor
(
poetry
:
Poetry
,
config
:
Config
,
env
:
MockEnv
)
->
TestExecutor
:
return
TestExecutor
(
env
,
poetry
.
pool
,
config
,
NullIO
())
@pytest.fixture
def
command_tester_factory
(
app
:
PoetryTestApplication
,
env
:
MockEnv
)
->
CommandTesterFactory
:
def
_tester
(
command
:
str
,
poetry
:
Poetry
|
None
=
None
,
installer
:
Installer
|
None
=
None
,
executor
:
Executor
|
None
=
None
,
environment
:
Env
|
None
=
None
,
)
->
CommandTester
:
command
=
app
.
find
(
command
)
tester
=
CommandTester
(
command
)
# Setting the formatter from the application
# TODO: Find a better way to do this in Cleo
app_io
=
app
.
create_io
()
formatter
=
app_io
.
output
.
formatter
tester
.
io
.
output
.
set_formatter
(
formatter
)
tester
.
io
.
error_output
.
set_formatter
(
formatter
)
if
poetry
:
app
.
_poetry
=
poetry
poetry
=
app
.
poetry
command
.
_pool
=
poetry
.
pool
if
hasattr
(
command
,
"set_env"
):
command
.
set_env
(
environment
or
env
)
if
hasattr
(
command
,
"set_installer"
):
installer
=
installer
or
Installer
(
tester
.
io
,
env
,
poetry
.
package
,
poetry
.
locker
,
poetry
.
pool
,
poetry
.
config
,
executor
=
executor
or
TestExecutor
(
env
,
poetry
.
pool
,
poetry
.
config
,
tester
.
io
),
)
installer
.
use_executor
(
True
)
command
.
set_installer
(
installer
)
return
tester
return
_tester
@pytest.fixture
def
do_lock
(
command_tester_factory
:
CommandTesterFactory
,
poetry
:
Poetry
)
->
None
:
command_tester_factory
(
"lock"
)
.
execute
()
assert
poetry
.
locker
.
lock
.
exists
()
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