Skip to content

Commit

Permalink
Update error handling + test for newer urllib3
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Aug 12, 2019
1 parent 61ee258 commit 4c63406
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -13,7 +13,7 @@ before_install:
- sudo apt-get install -y openjdk-12-jdk

install:
- pip install ".[test]" urllib3==1.21.1
- pip install ".[test]"
- pip install coverage flake8

script:
Expand Down
3 changes: 2 additions & 1 deletion crate/crash/command.py
Expand Up @@ -576,7 +576,8 @@ def main():
cmd = _create_shell(crate_hosts, error_trace, output_writer, is_tty,
args, password=password)
except (ProgrammingError, LocationParseError) as e:
if '401' in e.message and not args.force_passwd_prompt:
msg = getattr(e, 'message', str(e))
if '401' in msg and not args.force_passwd_prompt:
if is_tty:
password = getpass()
try:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_integration.py
Expand Up @@ -249,7 +249,7 @@ def test_multiple_hosts(self):
tmphistory = tempfile.mkstemp()[1]
sys.argv = ["testcrash",
"-c", "select * from sys.cluster",
"--hosts", node.http_url, "300.300.300.300:123",
"--hosts", node.http_url, "127.0.0.1:1",
'--history', tmphistory,
'--format', 'tabular',
'-v',
Expand All @@ -262,8 +262,8 @@ def test_multiple_hosts(self):
self.assertEqual(exception_code, 0)
output = output.getvalue()
lines = output.split('\n')
self.assertTrue(re.match(r'^\| http://[\d\.:]+. *\| crate .*\| TRUE .*\| OK', lines[3]) is not None, lines[3])
self.assertTrue(re.match(r'^\| http://[\d\.:]+ .*\| NULL .*\| FALSE .*\| Server not available', lines[4]) is not None, lines[4])
self.assertRegex(lines[3], r'^\| http://[\d\.:]+ .*\| NULL .*\| FALSE .*\| Server not available')
self.assertRegex(lines[4], r'^\| http://[\d\.:]+. *\| crate .*\| TRUE .*\| OK')
finally:
try:
os.remove(tmphistory)
Expand Down

0 comments on commit 4c63406

Please sign in to comment.