New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest tests #17750

Merged
merged 5 commits into from Oct 24, 2018

Conversation

Projects
None yet
4 participants
@balloob
Member

balloob commented Oct 24, 2018

Description:

PR #17270 to make a better state restoration system didn't make it because it required PyTest tests for all tests that test state restoration which resulted in way more work than expected.

So this is an attempt to help tackle some of the work.

This converts our tests to use pytest assert instead of testcase self.assert*. The conversion is done using https://github.com/pytest-dev/unittest2pytest. Since it directly impacts the asserts, it was easy to test that there were no side effects.

CC @armills

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

balloob added some commits Oct 24, 2018

self.assertEqual(sensor.entity_id, "sensor.dyson_1")
assert not sensor.should_poll
assert sensor.state == 2
assert sensor.unit_of_measurement == None

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

comparison to None should be 'if cond is None:'

self.assertEqual(sensor.entity_id, "sensor.dyson_1")
assert not sensor.should_poll
assert sensor.state is None
assert sensor.unit_of_measurement == None

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

comparison to None should be 'if cond is None:'

self.assertEqual(sensor.entity_id, "sensor.dyson_1")
assert not sensor.should_poll
assert sensor.state == 5
assert sensor.unit_of_measurement == None

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

comparison to None should be 'if cond is None:'

self.assertEqual(sensor.entity_id, "sensor.dyson_1")
assert not sensor.should_poll
assert sensor.state is None
assert sensor.unit_of_measurement == None

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

comparison to None should be 'if cond is None:'

sensor.state_attributes[STATE_ALL_BANS], ['111.111.111.111']
)
assert sensor.state == '111.111.111.111'
assert sensor.state_attributes[STATE_CURRENT_BANS] == ['111.111.111.111']

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

line too long (81 > 79 characters)

self.hass.states
.get('sensor.current_energy_usage').state)
assert '0.411' == \
self.hass.states \

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

continuation line over-indented for visual indent

.get('sensor.current_energy_usage').state)
assert '0.411' == \
self.hass.states \
.get('sensor.current_energy_usage').state

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

continuation line over-indented for visual indent

self.hass.states
.get('sensor.current_energy_usage').state)
assert '0.411' == \
self.hass.states \

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

continuation line over-indented for visual indent

setup_component(self.hass, 'sensor',
{'dte_energy_bridge': DTE_ENERGY_BRIDGE_CONFIG}))
assert setup_component(self.hass, 'sensor',
{'dte_energy_bridge': DTE_ENERGY_BRIDGE_CONFIG})

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

continuation line under-indented for visual indent

'Dark Sky Summary')
assert state.state == 'Clear'
assert state.attributes.get('friendly_name') == \
'Dark Sky Summary'

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2018

continuation line over-indented for visual indent

balloob added some commits Oct 24, 2018

@balloob balloob merged commit 08fe7c3 into dev Oct 24, 2018

3 of 5 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA

@wafflebot wafflebot bot removed the in progress label Oct 24, 2018

@fabaff fabaff deleted the pytest-tests branch Oct 24, 2018

@balloob balloob referenced this pull request Nov 9, 2018

Merged

0.82 #18335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment