File: test_custom_yaml_loader.py

package info (click to toggle)
python-hiyapyco 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 436 kB
  • sloc: python: 2,012; makefile: 237
file content (46 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python

import sys
import os
import logging
import platform

basepath = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.dirname(basepath))

import hiyapyco

sys.path.insert(
    0,
    os.path.join(
        os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))), "lib"
    ),
)
import testsetup

logger = testsetup.setup(sys.argv[1:])

basepath = os.path.dirname(os.path.realpath(__file__))

print(
    "start test %s for hiyapyco %s using python %s (loglevel:%s)"
    % (
        __file__,
        hiyapyco.__version__,
        platform.python_version(),
        logging.getLevelName(logger.getEffectiveLevel()),
    )
)

logger.info("test custom yaml loader ...")


def custom_loader(stream):
    """Mock loader that doesn't actually read the yaml file"""
    return [{"custom_yaml": 42}]


conf = hiyapyco.load(os.path.join(basepath, "base.yaml"), loader_callback=custom_loader)
assert conf == {"custom_yaml": 42}

print("passed test %s" % __file__)