Skip to content

Commit

Permalink
[ENH] Add .env support.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBretticus committed Feb 17, 2024
1 parent 89469e4 commit 8588ca9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ __pycache__
.venv*
coverage.xml

# config
.env

# Home Assistant configuration
config/*
Expand Down
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ optional = true

[tool.poetry.group.test.dependencies]
pytest-homeassistant-custom-component = "^0.13.91"
python-dotenv = "^1.0.1"

[tool.pytest.ini_options]
testpaths = "tests"
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ poetry self add poetry-plugin-export
poetry config warnings.export false
#poetry config virtualenvs.in-project true
poetry completions bash >> ~/.bash_completion
poetry install
poetry install --with dev --with test

echo alias py=python >> ~/.bash_aliases
17 changes: 7 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os

from dotenv import load_dotenv
from unittest.mock import patch
import pytest

Expand All @@ -12,13 +15,7 @@ def auto_enable_custom_integrations(enable_custom_integrations):
yield


# This fixture is used to prevent HomeAssistant from attempting to create and dismiss persistent
# notifications. These calls would fail without this fixture since the persistent_notification
# integration is never loaded during a test.
@pytest.fixture(name="skip_notifications", autouse=True)
def skip_notifications_fixture():
"""Skip notification calls."""
with patch("homeassistant.components.persistent_notification.async_create"), patch(
"homeassistant.components.persistent_notification.async_dismiss"
):
yield
@pytest.fixture(autouse=True)
def auto_enable_local_env():
if os.path.exists(".env"):
load_dotenv(os.path.abspath(".env"))

0 comments on commit 8588ca9

Please sign in to comment.