mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
Assert text files are in utf8 (#350)
Read and write text files with utf8 encoding. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
parent
ef60f5b9f5
commit
d2f6e9866d
@ -150,7 +150,7 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if args.input_file:
|
if args.input_file:
|
||||||
with open(args.input_file, "r") as f:
|
with open(args.input_file, "r", encoding="utf8") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
elif args.input:
|
elif args.input:
|
||||||
content = args.input
|
content = args.input
|
||||||
@ -164,7 +164,7 @@ def main():
|
|||||||
)
|
)
|
||||||
if args.output_file:
|
if args.output_file:
|
||||||
# Write to file
|
# Write to file
|
||||||
with open(args.output_file, "w") as f:
|
with open(args.output_file, "w", encoding="utf8") as f:
|
||||||
f.write(extracted_content)
|
f.write(extracted_content)
|
||||||
else:
|
else:
|
||||||
# Write to std output
|
# Write to std output
|
||||||
|
@ -150,7 +150,7 @@ def main():
|
|||||||
config_md = generate_config_md()
|
config_md = generate_config_md()
|
||||||
if args.output_file:
|
if args.output_file:
|
||||||
# Write to file
|
# Write to file
|
||||||
with open(args.output_file, "w") as f:
|
with open(args.output_file, "w", encoding="utf8") as f:
|
||||||
f.write(config_md)
|
f.write(config_md)
|
||||||
else:
|
else:
|
||||||
# Write to std output
|
# Write to std output
|
||||||
|
@ -54,7 +54,7 @@ def main():
|
|||||||
openapi_spec_str = json.dumps(openapi_spec, indent=2)
|
openapi_spec_str = json.dumps(openapi_spec, indent=2)
|
||||||
if args.output_file:
|
if args.output_file:
|
||||||
# Write to file
|
# Write to file
|
||||||
with open(args.output_file, "w") as f:
|
with open(args.output_file, "w", encoding="utf8") as f:
|
||||||
f.write(openapi_spec_str)
|
f.write(openapi_spec_str)
|
||||||
else:
|
else:
|
||||||
# Write to std output
|
# Write to std output
|
||||||
|
@ -286,7 +286,7 @@ def main():
|
|||||||
openapi_md = generate_openapi_md()
|
openapi_md = generate_openapi_md()
|
||||||
if args.output_file:
|
if args.output_file:
|
||||||
# Write to file
|
# Write to file
|
||||||
with open(args.output_file, "w") as f:
|
with open(args.output_file, "w", encoding="utf8") as f:
|
||||||
f.write(openapi_md)
|
f.write(openapi_md)
|
||||||
else:
|
else:
|
||||||
# Write to std output
|
# Write to std output
|
||||||
|
@ -47,7 +47,7 @@ def test_openapi_md_current(config_eos):
|
|||||||
expected_spec_md_path = DIR_PROJECT_ROOT / "docs" / "_generated" / "openapi.md"
|
expected_spec_md_path = DIR_PROJECT_ROOT / "docs" / "_generated" / "openapi.md"
|
||||||
new_spec_md_path = DIR_TESTDATA / "openapi-new.md"
|
new_spec_md_path = DIR_TESTDATA / "openapi-new.md"
|
||||||
|
|
||||||
with open(expected_spec_md_path) as f_expected:
|
with open(expected_spec_md_path, encoding="utf8") as f_expected:
|
||||||
expected_spec_md = f_expected.read()
|
expected_spec_md = f_expected.read()
|
||||||
|
|
||||||
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
||||||
@ -59,7 +59,7 @@ def test_openapi_md_current(config_eos):
|
|||||||
|
|
||||||
spec_md = generate_openapi_md.generate_openapi_md()
|
spec_md = generate_openapi_md.generate_openapi_md()
|
||||||
|
|
||||||
with open(new_spec_md_path, "w") as f_new:
|
with open(new_spec_md_path, "w", encoding="utf8") as f_new:
|
||||||
f_new.write(spec_md)
|
f_new.write(spec_md)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -76,7 +76,7 @@ def test_config_md_current(config_eos):
|
|||||||
expected_config_md_path = DIR_PROJECT_ROOT / "docs" / "_generated" / "config.md"
|
expected_config_md_path = DIR_PROJECT_ROOT / "docs" / "_generated" / "config.md"
|
||||||
new_config_md_path = DIR_TESTDATA / "config-new.md"
|
new_config_md_path = DIR_TESTDATA / "config-new.md"
|
||||||
|
|
||||||
with open(expected_config_md_path) as f_expected:
|
with open(expected_config_md_path, encoding="utf8") as f_expected:
|
||||||
expected_config_md = f_expected.read()
|
expected_config_md = f_expected.read()
|
||||||
|
|
||||||
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
||||||
@ -88,7 +88,7 @@ def test_config_md_current(config_eos):
|
|||||||
|
|
||||||
config_md = generate_config_md.generate_config_md()
|
config_md = generate_config_md.generate_config_md()
|
||||||
|
|
||||||
with open(new_config_md_path, "w") as f_new:
|
with open(new_config_md_path, "w", encoding="utf8") as f_new:
|
||||||
f_new.write(config_md)
|
f_new.write(config_md)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -61,7 +61,7 @@ def sample_settings(config_eos):
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_forecast_data():
|
def sample_forecast_data():
|
||||||
"""Fixture that returns sample forecast data converted to pydantic model."""
|
"""Fixture that returns sample forecast data converted to pydantic model."""
|
||||||
with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r") as f_in:
|
with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r", encoding="utf8") as f_in:
|
||||||
input_data = f_in.read()
|
input_data = f_in.read()
|
||||||
return PVForecastAkkudoktor._validate_data(input_data)
|
return PVForecastAkkudoktor._validate_data(input_data)
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ def sample_forecast_data():
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_forecast_data_raw():
|
def sample_forecast_data_raw():
|
||||||
"""Fixture that returns raw sample forecast data."""
|
"""Fixture that returns raw sample forecast data."""
|
||||||
with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r") as f_in:
|
with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r", encoding="utf8") as f_in:
|
||||||
input_data = f_in.read()
|
input_data = f_in.read()
|
||||||
return input_data
|
return input_data
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ def sample_forecast_data_raw():
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_forecast_report():
|
def sample_forecast_report():
|
||||||
"""Fixture that returns sample forecast data report."""
|
"""Fixture that returns sample forecast data report."""
|
||||||
with open(FILE_TESTDATA_PV_FORECAST_RESULT_1, "r") as f_res:
|
with open(FILE_TESTDATA_PV_FORECAST_RESULT_1, "r", encoding="utf8") as f_res:
|
||||||
input_data = f_res.read()
|
input_data = f_res.read()
|
||||||
return input_data
|
return input_data
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ def sample_clearout_1_html():
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_clearout_1_data():
|
def sample_clearout_1_data():
|
||||||
"""Fixture that returns sample forecast data."""
|
"""Fixture that returns sample forecast data."""
|
||||||
with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "r") as f_in:
|
with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "r", encoding="utf8") as f_in:
|
||||||
json_str = f_in.read()
|
json_str = f_in.read()
|
||||||
data = WeatherClearOutside.from_json(json_str)
|
data = WeatherClearOutside.from_json(json_str)
|
||||||
return data
|
return data
|
||||||
@ -212,7 +212,7 @@ def test_development_forecast_data(mock_get, weather_provider, sample_clearout_1
|
|||||||
# Fill the instance
|
# Fill the instance
|
||||||
weather_provider.update_data(force_enable=True)
|
weather_provider.update_data(force_enable=True)
|
||||||
|
|
||||||
with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "w") as f_out:
|
with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "w", encoding="utf8") as f_out:
|
||||||
f_out.write(weather_provider.to_json())
|
f_out.write(weather_provider.to_json())
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user