Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Fix exception as variable syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
chambridge committed Jun 16, 2017
1 parent afa7521 commit df75647
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Makefile
Expand Up @@ -24,10 +24,9 @@ build: clean
$(PYTHON) setup.py build -f

clean:
-rm -f MANIFEST etc/version .figleaf_interesting
-rm -f MANIFEST etc/version
-rm -rf dist/ build/ test/coverage rpm-build/ rho.egg-info/
-rm -rf *~
-rm -rf .figleaf
-rm -rf docs/*.gz

install: build
Expand Down
2 changes: 1 addition & 1 deletion rho/clicommands.py
Expand Up @@ -76,7 +76,7 @@ def _read_in_file(filename):
hosts = file(os.path.expanduser(os.path.expandvars(filename)))
result = hosts.read().splitlines()
hosts.close()
except EnvironmentError, e:
except EnvironmentError as e:
sys.stderr.write('Error reading from %s: %s\n' % (filename, e))
hosts.close()
return result
Expand Down
22 changes: 11 additions & 11 deletions test/test_clicommand.py
Expand Up @@ -11,7 +11,7 @@

""" Unit tests for CLI """

import rho.clicommands
from rho.clicommands import *
from mock import Mock
import unittest
import sys
Expand Down Expand Up @@ -41,7 +41,7 @@ def _run_test(self, cmd, args):

def test_scan_facts_default(self):
try:
self._run_test(rho.clicommands.ScanCommand(), ["scan", "--profile", "profilename",
self._run_test(ScanCommand(), ["scan", "--profile", "profilename",
"--reset", "--reportfile",
"data/test_report.csv", "--facts",
"default", "ansible_forks",
Expand All @@ -51,7 +51,7 @@ def test_scan_facts_default(self):

def test_scan_facts_file(self):
try:
self._run_test(rho.clicommands.ScanCommand(), ["scan", "--profile", "profilename",
self._run_test(ScanCommand(), ["scan", "--profile", "profilename",
"--reset", "--reportfile",
"data/test_report.csv", "--facts",
"data/facts_test", "ansible_forks",
Expand All @@ -61,7 +61,7 @@ def test_scan_facts_file(self):

def test_scan_facts_list(self):
try:
self._run_test(rho.clicommands.ScanCommand(), ["scan", "--profile", "profilename",
self._run_test(ScanCommand(), ["scan", "--profile", "profilename",
"--reset", "--reportfile",
"data/test_report.csv", "--facts",
"Username_uname.all",
Expand All @@ -72,11 +72,11 @@ def test_scan_facts_list(self):
pass

def test_profile_list(self):
self._run_test(rho.clicommands.ProfileListCommand(), ["profile", "list"])
self._run_test(ProfileListCommand(), ["profile", "list"])

def test_profile_add_hosts_list(self):
try:
self._run_test(rho.clicommands.ProfileAddCommand(), ["profile", "add", "--name",
self._run_test(ProfileAddCommand(), ["profile", "add", "--name",
"profilename", "hosts",
"1.2.3.4", "1.2.3.[4:100]",
"--auths", "auth_1", "auth2"])
Expand All @@ -85,34 +85,34 @@ def test_profile_add_hosts_list(self):

def test_profile_add_hosts_file(self):
try:
self._run_test(rho.clicommands.ProfileAddCommand(), ["profile", "add", "--name",
self._run_test(ProfileAddCommand(), ["profile", "add", "--name",
"profilename", "hosts",
"data/hosts_test","--auths",
"auth_1", "auth2"])
except SystemExit:
pass

def test_auth_list(self):
self._run_test(rho.clicommands.AuthListCommand(), ["auth", "list"])
self._run_test(AuthListCommand(), ["auth", "list"])

# def test_auth_add(self):
# getpass = Mock()
# getpass.return_value = "pass"
# try:
# self._run_test(rho.clicommands.AuthAddCommand(), ["auth", "add", "--name", "test",
# self._run_test(AuthAddCommand(), ["auth", "add", "--name", "test",
# "--username", "test_user", "--password",
# "--sshkeyfile", "somefile"])
# except SystemExit:
# pass

def test_profile_add_nonexistent_auth(self):
self.assertRaises(SystemExit, self._run_test, rho.clicommands.ProfileAddCommand(),
self.assertRaises(SystemExit, self._run_test, ProfileAddCommand(),
["profile", "add", "--name", "profile", "hosts",
"1.2.3.4", "--auth", "doesnotexist"])

def test_bad_range_options(self):
# Should fail scanning range without a username:
self.assertRaises(SystemExit, self._run_test, rho.clicommands.ProfileAddCommand(),
self.assertRaises(SystemExit, self._run_test, ProfileAddCommand(),
["profile", "add", "--name",
"profilename", "hosts",
"a:d:b:s", "--auths",
Expand Down

0 comments on commit df75647

Please sign in to comment.