mirror of
https://github.com/python-poetry/install.python-poetry.org.git
synced 2024-11-22 14:10:54 -05:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
8db565cd0f
commit
3745592173
2 changed files with 38 additions and 17 deletions
|
@ -902,10 +902,8 @@ def main():
|
||||||
"--stderr",
|
"--stderr",
|
||||||
dest="stderr",
|
dest="stderr",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help=(
|
help=("Log installation errors to stderr instead of a log file."),
|
||||||
"Log installation errors to stderr instead of a log file."
|
default=False,
|
||||||
),
|
|
||||||
default=False
|
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -921,7 +919,9 @@ def main():
|
||||||
git=args.git,
|
git=args.git,
|
||||||
)
|
)
|
||||||
|
|
||||||
disable_log_file = args.stderr or string_to_bool(os.getenv("POETRY_LOG_STDERR", "0"))
|
disable_log_file = args.stderr or string_to_bool(
|
||||||
|
os.getenv("POETRY_LOG_STDERR", "0")
|
||||||
|
)
|
||||||
|
|
||||||
if not disable_log_file and string_to_bool(os.getenv("CI", "0")):
|
if not disable_log_file and string_to_bool(os.getenv("CI", "0")):
|
||||||
installer._write(
|
installer._write(
|
||||||
|
@ -929,7 +929,6 @@ def main():
|
||||||
)
|
)
|
||||||
disable_log_file = True
|
disable_log_file = True
|
||||||
|
|
||||||
|
|
||||||
if args.uninstall or string_to_bool(os.getenv("POETRY_UNINSTALL", "0")):
|
if args.uninstall or string_to_bool(os.getenv("POETRY_UNINSTALL", "0")):
|
||||||
return installer.uninstall()
|
return installer.uninstall()
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from unittest.mock import MagicMock, patch
|
import importlib
|
||||||
import re
|
import re
|
||||||
import typing
|
import typing
|
||||||
import importlib
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
|
||||||
module = importlib.import_module("install-poetry")
|
module = importlib.import_module("install-poetry")
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ class InstallPoetryTestCase(unittest.TestCase):
|
||||||
force=False,
|
force=False,
|
||||||
accept_all=True,
|
accept_all=True,
|
||||||
path=None,
|
path=None,
|
||||||
git=None
|
git=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.__installer.uninstall.assert_not_called()
|
self.__installer.uninstall.assert_not_called()
|
||||||
|
@ -79,8 +81,12 @@ class InstallPoetryTestCase(unittest.TestCase):
|
||||||
|
|
||||||
return_code = module.main()
|
return_code = module.main()
|
||||||
|
|
||||||
self.__assert_no_matching_message("error", re.compile("a fake poetry installation error"))
|
self.__assert_no_matching_message(
|
||||||
self.__assert_any_matching_message("error", re.compile(f"See {self.__tmp_file} for error logs"))
|
"error", re.compile("a fake poetry installation error")
|
||||||
|
)
|
||||||
|
self.__assert_any_matching_message(
|
||||||
|
"error", re.compile(f"See {self.__tmp_file} for error logs")
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(return_code, 1)
|
self.assertEqual(return_code, 1)
|
||||||
self.__mock_path_cls(self.__tmp_file).write_text.assert_called_once()
|
self.__mock_path_cls(self.__tmp_file).write_text.assert_called_once()
|
||||||
|
@ -94,7 +100,9 @@ class InstallPoetryTestCase(unittest.TestCase):
|
||||||
return_code = module.main()
|
return_code = module.main()
|
||||||
|
|
||||||
self.__assert_no_matching_message("info", re.compile("CI environment detected"))
|
self.__assert_no_matching_message("info", re.compile("CI environment detected"))
|
||||||
self.__assert_any_matching_message("error", re.compile("a fake poetry installation error"))
|
self.__assert_any_matching_message(
|
||||||
|
"error", re.compile("a fake poetry installation error")
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(return_code, 1)
|
self.assertEqual(return_code, 1)
|
||||||
self.__mock_path_cls.assert_not_called()
|
self.__mock_path_cls.assert_not_called()
|
||||||
|
@ -108,7 +116,9 @@ class InstallPoetryTestCase(unittest.TestCase):
|
||||||
return_code = module.main()
|
return_code = module.main()
|
||||||
|
|
||||||
self.__assert_no_matching_message("info", re.compile("CI environment detected"))
|
self.__assert_no_matching_message("info", re.compile("CI environment detected"))
|
||||||
self.__assert_any_matching_message("error", re.compile("a fake poetry installation error"))
|
self.__assert_any_matching_message(
|
||||||
|
"error", re.compile("a fake poetry installation error")
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(return_code, 1)
|
self.assertEqual(return_code, 1)
|
||||||
self.__mock_path_cls.assert_not_called()
|
self.__mock_path_cls.assert_not_called()
|
||||||
|
@ -121,8 +131,12 @@ class InstallPoetryTestCase(unittest.TestCase):
|
||||||
|
|
||||||
return_code = module.main()
|
return_code = module.main()
|
||||||
|
|
||||||
self.__assert_any_matching_message("info", re.compile("CI environment detected"))
|
self.__assert_any_matching_message(
|
||||||
self.__assert_any_matching_message("error", re.compile("a fake poetry installation error"))
|
"info", re.compile("CI environment detected")
|
||||||
|
)
|
||||||
|
self.__assert_any_matching_message(
|
||||||
|
"error", re.compile("a fake poetry installation error")
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(return_code, 1)
|
self.assertEqual(return_code, 1)
|
||||||
self.__mock_path_cls.assert_not_called()
|
self.__mock_path_cls.assert_not_called()
|
||||||
|
@ -131,7 +145,9 @@ class InstallPoetryTestCase(unittest.TestCase):
|
||||||
self.__messages.append((severity, message))
|
self.__messages.append((severity, message))
|
||||||
return f"{severity}:{message}"
|
return f"{severity}:{message}"
|
||||||
|
|
||||||
def __getenv(self, key: str, default: typing.Optional[str] = None) -> typing.Optional[str]:
|
def __getenv(
|
||||||
|
self, key: str, default: typing.Optional[str] = None
|
||||||
|
) -> typing.Optional[str]:
|
||||||
return self.__env.get(key, default)
|
return self.__env.get(key, default)
|
||||||
|
|
||||||
def __mkstemp(self, suffix="suffix", prefix="prefix", dir=None, text=None):
|
def __mkstemp(self, suffix="suffix", prefix="prefix", dir=None, text=None):
|
||||||
|
@ -145,4 +161,10 @@ class InstallPoetryTestCase(unittest.TestCase):
|
||||||
self.assertEqual(self.__count_matching_message(severity, pattern), 0)
|
self.assertEqual(self.__count_matching_message(severity, pattern), 0)
|
||||||
|
|
||||||
def __count_matching_message(self, severity: str, pattern: re.Pattern):
|
def __count_matching_message(self, severity: str, pattern: re.Pattern):
|
||||||
return len([message for message in self.__messages if severity == message[0] and pattern.search(message[1])])
|
return len(
|
||||||
|
[
|
||||||
|
message
|
||||||
|
for message in self.__messages
|
||||||
|
if severity == message[0] and pattern.search(message[1])
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue