2021-03-08 01:05:08 +01:00
|
|
|
"""Fixtures for component tests."""
|
2020-07-15 14:04:00 +02:00
|
|
|
|
|
|
|
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():
|
2021-03-08 01:05:08 +01:00
|
|
|
"""Generates the C++ main.cpp file and returns it in string form."""
|
2020-07-15 14:04:00 +02:00
|
|
|
|
|
|
|
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()
|