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

testit-tms / adapters-python / 18458385700

13 Oct 2025 07:29AM UTC coverage: 36.912% (-6.3%) from 43.239%
18458385700

Pull #206

github

web-flow
Merge 9245f7686 into 4388b91e3
Pull Request #206: Fix/rollback the use of utc to support python 3.9

0 of 3 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

1286 of 3484 relevant lines covered (36.91%)

0.74 hits per line

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

0.0
/testit-python-commons/src/testit_python_commons/step.py
NEW
1
from datetime import datetime
×
2
import logging
×
3
from functools import wraps
×
4
from typing import Any, Callable, TypeVar
×
5

6
from testit_python_commons.models.step_result import StepResult
×
7
from testit_python_commons.services import (
×
8
    TmsPluginManager,
9
    Utils
10
)
11

12

13
Func = TypeVar("Func", bound=Callable[..., Any])
×
14

15

16
def step(*args, **kwargs):
×
17
    if callable(args[0]):
×
18
        function = args[0]
×
19
        return StepContext(function.__name__, None, {})(function)
×
20
    else:
21
        title = get_title(args, kwargs)
×
22
        description = get_description(args, kwargs)
×
23

24
        return StepContext(title, description, {})
×
25

26

27
def get_title(args: tuple, kwargs: dict):
×
28
    if 'title' in kwargs:
×
29
        return kwargs['title']
×
30

31
    if len(args) > 0:
×
32
        if isinstance(args[0], str):
×
33
            return args[0]
×
34

35
        logging.error(f'Cannot to get step title: {args[1]}. The title must be of string type.')
×
36

37

38
def get_description(args: tuple, kwargs: dict):
×
39
    if 'description' in kwargs:
×
40
        return kwargs['description']
×
41

42
    if len(args) > 1:
×
43
        if isinstance(args[1], str):
×
44
            return args[1]
×
45
        logging.error(f'Cannot to get step description: {args[1]}. The description must be of string type.')
×
46

47

48
class StepContext:
×
49
    def __init__(self, title, description, parameters):
×
50
        self.__title = title
×
51
        self.__description = description
×
52
        self.__parameters = parameters
×
53

54
    def __enter__(self):
×
NEW
55
        self.__start_time = round(datetime.utcnow().timestamp() * 1000)
×
56
        self.__step_result = StepResult()
×
57

58
        self.__title = Utils.collect_parameters_in_string_attribute(self.__title, self.__parameters)
×
59
        self.__description = Utils.collect_parameters_in_string_attribute(self.__description, self.__parameters)
×
60

61
        self.__step_result\
×
62
            .set_title(self.__title)\
63
            .set_description(self.__description)\
64
            .set_parameters(
65
                Utils.exclude_self_parameter(self.__parameters)
66
            )
67

68
        logging.debug(f'Step "{self.__title}" was started')
×
69

70
        TmsPluginManager.get_step_manager().start_step(self.__step_result)
×
71

72
    def __exit__(self, exc_type, exc_val, exc_tb):
×
73
        outcome = 'Failed' if exc_type \
×
74
            else TmsPluginManager.get_plugin_manager().hook.get_pytest_check_outcome()[0] if \
75
            hasattr(TmsPluginManager.get_plugin_manager().hook, 'get_pytest_check_outcome') \
76
            else 'Passed'
NEW
77
        duration = round(datetime.utcnow().timestamp() * 1000) - self.__start_time
×
78

79
        self.__step_result\
×
80
            .set_outcome(outcome)\
81
            .set_duration(duration)
82

83
        TmsPluginManager.get_step_manager().stop_step()
×
84

85
    def __call__(self, function: Func) -> Func:
×
86
        @wraps(function)
×
87
        def impl(*args, **kwargs):
×
88
            __tracebackhide__ = True
×
89
            parameters = Utils.get_function_parameters(function, *args, **kwargs)
×
90

91
            title = self.__title if self.__title else function.__name__
×
92

93
            with StepContext(title, self.__description, parameters):
×
94
                return function(*args, **kwargs)
×
95

96
        return impl
×
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