|
12 | 12 | import boto3 |
13 | 13 | import pytest |
14 | 14 | import hcl2 |
| 15 | +from hcl2 import SerializationOptions |
| 16 | + |
| 17 | +HCL2_SERIALIZATION_OPTIONS = SerializationOptions( |
| 18 | + strip_string_quotes=True, explicit_blocks=False, with_comments=False |
| 19 | +) |
15 | 20 |
|
16 | 21 | # TODO set up the tests to run with tox so we can run the tests with different python versions |
17 | 22 |
|
@@ -385,7 +390,7 @@ def test_s3_remote_data_source_with_workspace(monkeypatch): |
385 | 390 | assert check_override_file_exists(override_file) |
386 | 391 |
|
387 | 392 | with open(override_file, "r") as fp: |
388 | | - result = hcl2.load(fp) |
| 393 | + result = hcl2.load(fp, serialization_options=HCL2_SERIALIZATION_OPTIONS) |
389 | 394 | assert result["data"][0]["terraform_remote_state"]["terraform_infra"]["workspace"] == "${terraform.workspace}" |
390 | 395 | assert result["data"][1]["terraform_remote_state"]["build_infra"]["workspace"] == "build" |
391 | 396 |
|
@@ -432,7 +437,7 @@ def test_versioned_endpoints(monkeypatch, provider_version): |
432 | 437 | assert check_override_file_exists(override_file) |
433 | 438 |
|
434 | 439 | with open(override_file, "r") as fp: |
435 | | - result = hcl2.load(fp) |
| 440 | + result = hcl2.load(fp, serialization_options=HCL2_SERIALIZATION_OPTIONS) |
436 | 441 | endpoints = result["provider"][0]["aws"]["endpoints"][0] |
437 | 442 | if provider_version == "5.99.1": |
438 | 443 | assert "iotanalytics" in endpoints |
@@ -486,7 +491,7 @@ def test_subdomain_endpoints(monkeypatch, endpoint_host): |
486 | 491 | assert check_override_file_exists(override_file) |
487 | 492 |
|
488 | 493 | with open(override_file, "r") as fp: |
489 | | - result = hcl2.load(fp) |
| 494 | + result = hcl2.load(fp, serialization_options=HCL2_SERIALIZATION_OPTIONS) |
490 | 495 | endpoints = result["provider"][0]["aws"]["endpoints"][0] |
491 | 496 | assert "s3control" in endpoints |
492 | 497 | assert "mwaa" in endpoints |
@@ -570,7 +575,7 @@ def test_service_endpoint_alias_replacements(monkeypatch): |
570 | 575 | def check_override_file_content(override_file): |
571 | 576 | try: |
572 | 577 | with open(override_file, "r") as fp: |
573 | | - result = hcl2.load(fp) |
| 578 | + result = hcl2.load(fp, serialization_options=HCL2_SERIALIZATION_OPTIONS) |
574 | 579 | result = result["provider"][0]["aws"] |
575 | 580 | except Exception as e: |
576 | 581 | raise Exception(f'Unable to parse "{override_file}" as HCL file: {e}') |
@@ -616,7 +621,7 @@ def test_s3_backend_configs_merge(monkeypatch): |
616 | 621 | def check_override_file_backend_extra_content(override_file): |
617 | 622 | try: |
618 | 623 | with open(override_file, "r") as fp: |
619 | | - result = hcl2.load(fp) |
| 624 | + result = hcl2.load(fp, serialization_options=HCL2_SERIALIZATION_OPTIONS) |
620 | 625 | result = result["terraform"][0]["backend"][0]["s3"] |
621 | 626 | except Exception as e: |
622 | 627 | raise Exception(f'Unable to parse "{override_file}" as HCL file: {e}') |
@@ -690,7 +695,7 @@ def check_override_file_backend_endpoints_content(override_file, is_legacy: bool |
690 | 695 | } |
691 | 696 | try: |
692 | 697 | with open(override_file, "r") as fp: |
693 | | - result = hcl2.load(fp) |
| 698 | + result = hcl2.load(fp, serialization_options=HCL2_SERIALIZATION_OPTIONS) |
694 | 699 | result = result["terraform"][0]["backend"][0]["s3"] |
695 | 700 | except Exception as e: |
696 | 701 | print(f'Unable to parse "{override_file}" as HCL file: {e}') |
@@ -727,7 +732,7 @@ def test_provider_aliases_ignored(monkeypatch): |
727 | 732 | def check_override_file_content_for_alias(override_file): |
728 | 733 | try: |
729 | 734 | with open(override_file, "r") as fp: |
730 | | - result = hcl2.load(fp) |
| 735 | + result = hcl2.load(fp, serialization_options=HCL2_SERIALIZATION_OPTIONS) |
731 | 736 | result = result["provider"] |
732 | 737 | except Exception as e: |
733 | 738 | raise Exception(f'Unable to parse "{override_file}" as HCL file: {e}') |
|
0 commit comments