Skip to content

Commit 2f567cc

Browse files
committed
tests: Drop old clicomm infrastructure
Signed-off-by: Cole Robinson <[email protected]>
1 parent 567be2a commit 2f567cc

1 file changed

Lines changed: 2 additions & 66 deletions

File tree

tests/__init__.py

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
2-
from __future__ import print_function
1+
# This work is licensed under the GNU GPLv2 or later.
2+
# See the COPYING file in the top-level directory.
33

44
import os
5-
import shlex
6-
import sys
7-
8-
# pylint: disable=import-error
9-
if sys.version_info[0] >= 3:
10-
from io import StringIO
11-
else:
12-
from StringIO import StringIO
13-
# pylint: enable=import-error
14-
15-
from bugzilla import Bugzilla, RHBugzilla, _cli
165

176

187
class _CLICONFIG(object):
@@ -23,56 +12,3 @@ def __init__(self):
2312

2413
CLICONFIG = _CLICONFIG()
2514
os.environ["__BUGZILLA_UNITTEST"] = "1"
26-
27-
28-
def clicomm(argvstr, bzinstance,
29-
returnmain=False, stdin=None, expectfail=False):
30-
"""
31-
Run bin/bugzilla.main() directly with passed argv
32-
"""
33-
34-
argv = shlex.split(argvstr)
35-
36-
oldstdout = sys.stdout
37-
oldstderr = sys.stderr
38-
oldstdin = sys.stdin
39-
oldargv = sys.argv
40-
try:
41-
out_io = StringIO()
42-
sys.stdout = out_io
43-
sys.stderr = out_io
44-
if stdin:
45-
sys.stdin = stdin
46-
47-
sys.argv = argv
48-
49-
ret = 0
50-
test_return = None
51-
try:
52-
print(" ".join(argv))
53-
print()
54-
55-
test_return = _cli.main(unittest_bz_instance=bzinstance)
56-
except SystemExit as sys_e:
57-
ret = sys_e.code
58-
59-
outstr = out_io.getvalue()
60-
if outstr.endswith("\n"):
61-
outstr = outstr[:-1]
62-
63-
if ret != 0 and not expectfail:
64-
raise RuntimeError("Command failed with %d\ncmd=%s\nout=%s" %
65-
(ret, argvstr, outstr))
66-
if ret == 0 and expectfail:
67-
raise RuntimeError("Command succeeded but we expected success\n"
68-
"ret=%d\ncmd=%s\nout=%s" %
69-
(ret, argvstr, outstr))
70-
71-
if returnmain:
72-
return test_return
73-
return outstr
74-
finally:
75-
sys.stdout = oldstdout
76-
sys.stderr = oldstderr
77-
sys.stdin = oldstdin
78-
sys.argv = oldargv

0 commit comments

Comments
 (0)