• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

localstack / localstack / 21765279428

06 Feb 2026 08:43PM UTC coverage: 73.535% (-13.3%) from 86.871%
21765279428

Pull #13716

github

web-flow
Merge 0f5988375 into 20cc1b384
Pull Request #13716: Events: improve Store IAM Statement typing

6 of 6 new or added lines in 1 file covered. (100.0%)

9920 existing lines in 273 files now uncovered.

56187 of 76409 relevant lines covered (73.53%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.68
/localstack-core/localstack/testing/aws/cloudformation_utils.py
1
import os
1✔
2
import pathlib
1✔
3

4
import jinja2
1✔
5

6
from localstack.utils.common import load_file
1✔
7

8

9
def load_template_file(file_path: str | os.PathLike, *, path_ctx: str | os.PathLike = None) -> str:
1✔
10
    """
11
    Load a cloudformation file (YAML or JSON)
12

13
    Note this now requires providing the file_path as a proper structured object.
14
    In turn this makes it easier to find proper templates by using IDE autocomplete features when selecting templates
15

16
    :param file_path: path to file
17
    :param path_ctx: *must* be provided if file_path is not an absolute path
18

19
    :returns default encoded string representation of file contents
20
    """
21

22
    file_path_obj = pathlib.Path(file_path)
1✔
23

24
    if file_path_obj.suffix not in [".yaml", ".yml", ".json"]:
1✔
25
        raise ValueError("Unsupported suffix for template file")
×
26

27
    if path_ctx is not None:
1✔
28
        file_path_obj = file_path_obj.relative_to(path_ctx)
×
29
    elif not file_path_obj.is_absolute():
1✔
UNCOV
30
        raise ValueError("Provided path must be absolute if no path_ctx is provided")
×
31

32
    return load_file(file_path_obj.absolute(), strict=True)
1✔
33

34

35
# TODO: TBH this utility really doesn't add anything, probably better to just remove it
36
def render_template(template_body: str, **template_vars) -> str:
1✔
37
    """render a template with jinja"""
38
    if template_vars:
1✔
UNCOV
39
        template_body = jinja2.Template(template_body).render(**template_vars)
×
40
    return template_body
1✔
41

42

43
def load_template_raw(path: str):
1✔
UNCOV
44
    return load_template_file(path)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc