Tests for CPP Code generation and some Python3 improvements (#961)

* Basic pytest configuration

* Added unit_test script that triggers pytest

* Changed "fixtures" to fixture_path

This is consistent with pytest's tmp_path

* Initial unit tests for esphome.helpers

* Disabled coverage reporting for esphome/components.

Focus initial unittest efforts on the core code.

* Migrated some ip_address to hypothesis

* Added a hypothesis MAC address strategy

* Initial tests for core

* Added hypothesis to requirements

* Added tests for core classes

TestTimePeriod
Lambda
ID
DocumentLocation
DocumentRange
Define
Library

* Updated test config so package root is discovered

* Setup fixtures and inital tests for pins

* Added tests for validate GPIO

* Added tests for pin type

* Added initial config_validation tests

* Added more tests for config_validation

* Added comparison unit tests

* Added repr to core.TimePeriod. Simplified identifying faults in tests

* Fixed inverted gt/lt tests

* Some tests for Espcore

* Updated syntax for Python3

* Removed usage of kwarg that isn't required

* Started writing test cases

* Started writing test cases for cpp_generator

* Additional docs and more Python3 releated improvements

* More test cases for cpp_generator.

* Fixed linter errors

* Add codegen tests to ensure file API remains stable

* Add test cases for cpp_helpers
This commit is contained in:
Tim Savage
2020-04-20 10:05:58 +10:00
committed by GitHub
parent 269812e781
commit d447548893
9 changed files with 574 additions and 170 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ def to_code(config):
initial_value = cg.RawExpression(config[CONF_INITIAL_VALUE])
rhs = GlobalsComponent.new(template_args, initial_value)
glob = cg.Pvariable(config[CONF_ID], rhs, type=res_type)
glob = cg.Pvariable(config[CONF_ID], rhs, res_type)
yield cg.register_component(glob, config)
if config[CONF_RESTORE_VALUE]:
+1 -1
View File
@@ -169,7 +169,7 @@ def to_code(config):
else:
out_type = NeoPixelRGBLightOutput.template(template)
rhs = out_type.new()
var = cg.Pvariable(config[CONF_OUTPUT_ID], rhs, type=out_type)
var = cg.Pvariable(config[CONF_OUTPUT_ID], rhs, out_type)
yield light.register_light(var, config)
yield cg.register_component(var, config)
@@ -57,10 +57,10 @@ def to_code(config):
model_type, model = MODELS[config[CONF_MODEL]]
if model_type == 'a':
rhs = WaveshareEPaperTypeA.new(model)
var = cg.Pvariable(config[CONF_ID], rhs, type=WaveshareEPaperTypeA)
var = cg.Pvariable(config[CONF_ID], rhs, WaveshareEPaperTypeA)
elif model_type == 'b':
rhs = model.new()
var = cg.Pvariable(config[CONF_ID], rhs, type=model)
var = cg.Pvariable(config[CONF_ID], rhs, model)
else:
raise NotImplementedError()