public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob c29fcc1e000a92beb9a8a9091763b94cebc6203a 1782 bytes (raw)

 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 
#! /usr/bin/env python3

# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>

"""
Test writer facing interface to avocodo-classless
"""

from collections import Counter

from .manifest import manifest_add


def test(func):
    """Function decorator to mark a function as a classless test"""
    manifest_add(func.__module__, func.__name__, func)
    return func


def test_output(*tests):
    """Decorate a function to test its output with a list of other functions"""
    def dec(func):
        for testfn in tests:
            manifest_add(func.__module__,
                         f"{testfn.__name__}∘{func.__name__}",
                         lambda testfn=testfn: testfn(func()))

        return func
    return dec


#
# Assertion helpers without unnecessary OOP nonsense
#


def assert_eq(left, right):
    """assert_eq(left, right)

    If left != right, fail with message showing both values
    """
    assert (left == right), f'{left} != {right}'


def assert_in(member, group):
    """assert_in(member, group)

    If member not in group, fail with a message showing both values
    """
    assert member in group, f'{member} not in {group}'


def assert_eq_unordered(left, right):
    """assert_eq_unordered(left, right)

    Fails if sequences left and right are different, ignoring order.
    """
    assert Counter(left) == Counter(right), \
        f'{left} != {right} (ignoring order)'


def assert_raises(exc, func, *args, **kwargs):
    """assert_raises(exc, func, *args, **kwargs)

    If func(*args, **kwargs) does not raise exc, fail
    """
    try:
        func(*args, **kwargs)
        raise AssertionError(f'Expected {exc.__name__} exception')
    except exc:
        pass

debug log:

solving e5251960 ...
found e5251960 in https://archives.passt.top/passt-dev/20230627025429.2209702-10-david@gibson.dropbear.id.au/
found 0602f9c9 in https://archives.passt.top/passt-dev/20230627025429.2209702-8-david@gibson.dropbear.id.au/
found eb2caef2 in https://archives.passt.top/passt-dev/20230627025429.2209702-7-david@gibson.dropbear.id.au/

applying [1/3] https://archives.passt.top/passt-dev/20230627025429.2209702-7-david@gibson.dropbear.id.au/
diff --git a/test/avocado_classless/avocado_classless/test.py b/test/avocado_classless/avocado_classless/test.py
new file mode 100644
index 00000000..eb2caef2


applying [2/3] https://archives.passt.top/passt-dev/20230627025429.2209702-8-david@gibson.dropbear.id.au/
diff --git a/test/avocado_classless/avocado_classless/test.py b/test/avocado_classless/avocado_classless/test.py
index eb2caef2..0602f9c9 100644


applying [3/3] https://archives.passt.top/passt-dev/20230627025429.2209702-10-david@gibson.dropbear.id.au/
diff --git a/test/avocado_classless/avocado_classless/test.py b/test/avocado_classless/avocado_classless/test.py\r
index 0602f9c9..e5251960 100644\r

Checking patch test/avocado_classless/avocado_classless/test.py...
Applied patch test/avocado_classless/avocado_classless/test.py cleanly.
Checking patch test/avocado_classless/avocado_classless/test.py...
Applied patch test/avocado_classless/avocado_classless/test.py cleanly.
Checking patch test/avocado_classless/avocado_classless/test.py...
Applied patch test/avocado_classless/avocado_classless/test.py cleanly.

index at:
100644 c29fcc1e000a92beb9a8a9091763b94cebc6203a	test/avocado_classless/avocado_classless/test.py

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).