Skip to content
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

Migrate tests to pytest #23544

Merged
merged 4 commits into from
Apr 30, 2019
Merged

Conversation

emontnemery
Copy link
Contributor

Description:

Migrate some tests to pytest
Also some minor cleanup of tests

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

def setUp(self):
"""Set up the tests."""
self.hass = get_test_home_assistant()
self.hass.config.unit_system = METRIC_SYSTEM
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore

"""Run when tests are started."""
self.hass = get_test_home_assistant()
run_coroutine_threadsafe(async_setup_component(
self.hass, 'homeassistant', {}), self.hass.loop).result()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore after we refactored scene. Used to be that this would set up homeassistant.turn_on

def test_as_local_with_local_object():
"""Test local with local object."""
now = dt_util.now()
assert now == now
Copy link
Contributor Author

@emontnemery emontnemery Apr 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaningless test, added here: e0ecb64
@balloob Any idea what this was intended to test?

try:
asyncio.get_event_loop()
except RuntimeError:
asyncio.set_event_loop(asyncio.new_event_loop())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use the loop fixture from aiohttp.pytest_plugin instead.

Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, very impressive, great work 🎉

@balloob
Copy link
Member

balloob commented Apr 30, 2019

Looked at some of the CI results, and saw between 40s-1m30s speed bump!

@balloob balloob merged commit 407e0c5 into home-assistant:dev Apr 30, 2019
@balloob balloob mentioned this pull request May 14, 2019
@emontnemery emontnemery deleted the core_tests_cleanup branch September 6, 2019 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants