Pytest tests (#17750)

* Convert core tests

* Convert component tests to use pytest assert

* Lint 🤷‍♂️

* Fix test

* Fix 3 typos in docs
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2018-10-24 12:10:05 +02:00
1 parent 4222f7562b
commit 08fe7c3ece
223 files changed
+6747 -7237

No files matched your search

+7 -7
View File
@@ -18,11 +18,11 @@ class TestLockDemo(unittest.TestCase):
def setUp(self): # pylint: disable=invalid-name
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.assertTrue(setup_component(self.hass, lock.DOMAIN, {
assert setup_component(self.hass, lock.DOMAIN, {
'lock': {
'platform': 'demo'
}
}))
})
def tearDown(self): # pylint: disable=invalid-name
"""Stop everything that was started."""
@@ -30,10 +30,10 @@ class TestLockDemo(unittest.TestCase):
def test_is_locked(self):
"""Test if lock is locked."""
self.assertTrue(lock.is_locked(self.hass, FRONT))
assert lock.is_locked(self.hass, FRONT)
self.hass.states.is_state(FRONT, 'locked')
self.assertFalse(lock.is_locked(self.hass, KITCHEN))
assert not lock.is_locked(self.hass, KITCHEN)
self.hass.states.is_state(KITCHEN, 'unlocked')
def test_locking(self):
@@ -41,18 +41,18 @@ class TestLockDemo(unittest.TestCase):
common.lock(self.hass, KITCHEN)
self.hass.block_till_done()
self.assertTrue(lock.is_locked(self.hass, KITCHEN))
assert lock.is_locked(self.hass, KITCHEN)
def test_unlocking(self):
"""Test the unlocking of a lock."""
common.unlock(self.hass, FRONT)
self.hass.block_till_done()
self.assertFalse(lock.is_locked(self.hass, FRONT))
assert not lock.is_locked(self.hass, FRONT)
def test_opening(self):
"""Test the opening of a lock."""
calls = mock_service(self.hass, lock.DOMAIN, lock.SERVICE_OPEN)
common.open_lock(self.hass, OPENABLE_LOCK)
self.hass.block_till_done()
self.assertEqual(1, len(calls))
assert 1 == len(calls)