Skip to content

Commit 3dbc36f

Browse files
committed
cmdeploy: remove colors from cmdeploy init again, hard to test
1 parent 990865c commit 3dbc36f

2 files changed

Lines changed: 9 additions & 25 deletions

File tree

cmdeploy/src/cmdeploy/cmdeploy.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
# cmdeploy sub commands and options
2626
#
2727

28-
def is_pytest():
29-
return "PYTEST_CURRENT_TEST" in os.environ
30-
3128

3229
def init_cmd_options(parser):
3330
parser.add_argument(
@@ -49,15 +46,18 @@ def init_cmd(args, out):
4946
inipath = args.inipath
5047
if args.inipath.exists():
5148
if not args.recreate_ini:
52-
out.green(f"[WARNING] Path exists, not modifying: {inipath}")
49+
print(f"[WARNING] Path exists, not modifying: {inipath}")
5350
return 1
5451
else:
55-
out.yellow(f"[WARNING] Force argument was provided, deleting config file: {inipath}")
52+
print(
53+
f"[WARNING] Force argument was provided, deleting config file: {inipath}"
54+
)
5655
inipath.unlink()
5756

5857
write_initial_config(inipath, mail_domain, overrides={})
5958
out.green(f"created config file for {mail_domain} in {inipath}")
6059

60+
6161
def run_cmd_options(parser):
6262
parser.add_argument(
6363
"--dry-run",
@@ -276,20 +276,11 @@ class Out:
276276
def red(self, msg, file=sys.stderr):
277277
print(colored(msg, "red"), file=file)
278278

279-
def green(self, msg, file=sys.stdout):
279+
def green(self, msg, file=sys.stderr):
280280
print(colored(msg, "green"), file=file)
281281

282-
def yellow(self, msg, file=sys.stdout):
283-
print(colored(msg, "yellow"), file=file)
284-
285-
def __call__(self, msg, red=False, green=False, yellow=False, file=sys.stdout):
286-
color = None
287-
if red:
288-
color = "red"
289-
elif green:
290-
color = "green"
291-
elif yellow:
292-
color = "yellow"
282+
def __call__(self, msg, red=False, green=False, file=sys.stdout):
283+
color = "red" if red else ("green" if green else None)
293284
print(colored(msg, color), file=file)
294285

295286
def check_call(self, arg, env=None, quiet=False):
@@ -374,12 +365,6 @@ def get_sshexec():
374365
args.get_sshexec = get_sshexec
375366

376367
out = Out()
377-
if is_pytest(): ## issue: https://github.com/chatmail/relay/issues/622
378-
out.green = print
379-
out.red = print
380-
out.yellow = print
381-
out.__call__ = print
382-
383368
kwargs = {}
384369
if args.func.__name__ not in ("init_cmd", "fmt_cmd"):
385370
if not args.inipath.exists():

cmdeploy/src/cmdeploy/tests/test_cmdeploy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ def test_parser(self, capsys):
2525

2626
def test_init_not_overwrite(self, capsys):
2727
assert main(["init", "chat.example.org"]) == 0
28-
out, err = capsys.readouterr()
29-
assert "created config file" in out.lower()
28+
capsys.readouterr()
3029

3130
assert main(["init", "chat.example.org"]) == 1
3231
out, err = capsys.readouterr()

0 commit comments

Comments
 (0)