Skip to content

Commit

Permalink
Python 3.4 test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarkentin committed Jan 25, 2015
1 parent 60c10a7 commit 61cb54d
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions tests/test_utils.py
Expand Up @@ -17,25 +17,43 @@

class TestWatchman(unittest.TestCase):

def assertListsEqual(self, l1, l2):
try:
# Python 3.4
self.assertCountEqual(l1, l2)
except AttributeError:
# Python 2.7
self.assertItemsEqual(l1, l2)

def setUp(self):
pass

def test_get_checks_returns_all_available_checks_by_default(self):
self.assertEqual([check.__name__ for check in get_checks()], ['caches_status', 'email_status', 'databases_status'])
checks = [check.__name__ for check in get_checks()]
expected_checks = ['caches_status', 'email_status', 'databases_status']
self.assertListsEqual(checks, expected_checks)

def test_get_checks_with_check_list_returns_union(self):
check_list = ['watchman.checks.caches_status']
self.assertEqual([check.__name__ for check in get_checks(check_list=check_list)], ['caches_status'])
checks = [check.__name__ for check in get_checks(check_list=check_list)]
expected_checks = ['caches_status']
self.assertListsEqual(checks, expected_checks)

def test_get_checks_with_skip_list_returns_difference(self):
skip_list = ['watchman.checks.caches_status']
self.assertEqual([check.__name__ for check in get_checks(skip_list=skip_list)], ['databases_status', 'email_status'])
checks = [check.__name__ for check in get_checks(skip_list=skip_list)]
expected_checks = ['databases_status', 'email_status']
self.assertListsEqual(checks, expected_checks)

def test_get_checks_with_matching_check_and_skip_list_returns_empty_list(self):
check_list, skip_list = ['watchman.checks.caches_status'], ['watchman.checks.caches_status']
self.assertEqual([check.__name__ for check in get_checks(check_list=check_list, skip_list=skip_list)], [])
checks = [check.__name__ for check in get_checks(check_list=check_list, skip_list=skip_list)]
expected_checks = []
self.assertListsEqual(checks, expected_checks)

def test_get_checks_with_check_and_skip_list(self):
check_list = ['watchman.checks.caches_status', 'watchman.checks.databases_status']
skip_list = ['watchman.checks.caches_status']
self.assertEqual([check.__name__ for check in get_checks(check_list=check_list, skip_list=skip_list)], ['databases_status'])
checks = [check.__name__ for check in get_checks(check_list=check_list, skip_list=skip_list)]
expected_checks = ['databases_status']
self.assertListsEqual(checks, expected_checks)

0 comments on commit 61cb54d

Please sign in to comment.