Skip to content

Commit 7e08ca7

Browse files
s.logvinenkos.logvinenko
authored andcommitted
fix auth_test
1 parent df6e586 commit 7e08ca7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/auth_test.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212

1313
try:
14-
import pexpect
15-
except:
14+
from pexpect import *
15+
except ImportError:
1616
skip_test = True
1717

1818

@@ -90,7 +90,7 @@ def test_empty_password(self):
9090
run_pb_with_auth(self.cmd, '\0\r\n'))
9191
)
9292
)
93-
except (pexpect.TIMEOUT, pexpect.ExceptionPexpect) as e:
93+
except (TIMEOUT, ExceptionPexpect) as e:
9494
self.fail(e.value)
9595

9696
def test_wrong_password(self):
@@ -100,7 +100,7 @@ def test_wrong_password(self):
100100
run_pb_with_auth(self.cmd, 'wrong_password\r\n'))
101101
)
102102
)
103-
except (pexpect.TIMEOUT, pexpect.ExceptionPexpect) as e:
103+
except (TIMEOUT, ExceptionPexpect) as e:
104104
self.fail(e.value)
105105

106106
def test_right_password(self):
@@ -110,13 +110,13 @@ def test_right_password(self):
110110
run_pb_with_auth(self.cmd, 'password\r\n'))
111111
)
112112
)
113-
except (pexpect.TIMEOUT, pexpect.ExceptionPexpect) as e:
113+
except (TIMEOUT, ExceptionPexpect) as e:
114114
self.fail(e.value)
115115

116116
def test_ctrl_c_event(self):
117117
try:
118118
run_pb_with_auth(self.cmd, kill=True)
119-
except pexpect.TIMEOUT:
119+
except TIMEOUT:
120120
self.fail("Error: CTRL+C event ignored")
121121

122122

@@ -130,16 +130,16 @@ def modify_pg_hba(node):
130130

131131
def run_pb_with_auth(cmd, password=None, kill=False):
132132
try:
133-
with pexpect.spawn(" ".join(cmd), timeout=10) as probackup:
133+
with spawn(" ".join(cmd), timeout=10) as probackup:
134134
result = probackup.expect("Password for user .*:", 5)
135135
if kill:
136136
probackup.kill(signal.SIGINT)
137137
elif result == 0:
138138
probackup.sendline(password)
139139
return probackup.readlines()
140140
else:
141-
raise pexpect.TIMEOUT("")
142-
except pexpect.TIMEOUT:
143-
raise pexpect.TIMEOUT("Timeout error.")
144-
except pexpect.ExceptionPexpect:
145-
raise pexpect.ExceptionPexpect("Pexpect error.")
141+
raise TIMEOUT("")
142+
except TIMEOUT:
143+
raise TIMEOUT("Timeout error.")
144+
except ExceptionPexpect:
145+
raise ExceptionPexpect("Pexpect error.")

0 commit comments

Comments
 (0)