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

Mock Module + Platform default to async #12347

Merged
merged 2 commits into from
Feb 12, 2018
Merged

Mock Module + Platform default to async #12347

merged 2 commits into from
Feb 12, 2018

Conversation

balloob
Copy link
Member

@balloob balloob commented Feb 12, 2018

Description:

In tests, when using a mock module or mock platform, default to async setup methods so that we don't use the executor pool.

@homeassistant homeassistant added small-pr PRs with less than 30 lines. cla-signed labels Feb 12, 2018
tests/common.py Outdated
if self._setup is not None:
return self._setup(hass, config)
return True
if not setup and not async_setup:
Copy link
Member

@OttoWinter OttoWinter Feb 12, 2018

Choose a reason for hiding this comment

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

Style suggestion: You're using is not None above, but here you're suddenly checking for nullability (if i'm correct) with __nonzero__ . PEP8:

Comparisons to singletons like None should always be done with is or is not, never the equality operators.

Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@balloob balloob merged commit 870728f into dev Feb 12, 2018
@balloob balloob deleted the mock-tweaks branch February 12, 2018 18:59
@balloob balloob mentioned this pull request Feb 22, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed small-pr PRs with less than 30 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants