1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 11:22:24 +01:00

Feature/component test fixture (#1142)

This commit is contained in:
Peter Kuehne
2020-07-15 13:04:00 +01:00
committed by GitHub
parent d5c59292c8
commit 3ec9bcaed6
2 changed files with 54 additions and 12 deletions

View File

@@ -0,0 +1,23 @@
""" Fixtures for component tests """
import pytest
from esphome.core import CORE
from esphome.config import read_config
from esphome.__main__ import generate_cpp_contents
@pytest.fixture
def generate_main():
""" Generates the C++ main.cpp file and returns it in string form """
def generator(path: str) -> str:
CORE.config_path = path
CORE.config = read_config({})
generate_cpp_contents(CORE.config)
print(CORE.cpp_main_section)
return CORE.cpp_main_section
yield generator
CORE.reset()