summaryrefslogtreecommitdiff
path: root/test/integration/targets/ansible-test-units-forked/ansible_collections/ns/col/tests/unit/plugins/modules/test_ansible_forked.py
blob: 828099c65e4cf3e06e9baf4aa5937e84378d59ec (plain)
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
"""Unit tests to verify the functionality of the ansible-forked pytest plugin."""
from __future__ import absolute_import, division, print_function

__metaclass__ = type

import os
import pytest
import signal
import sys
import warnings


warnings.warn("This verifies that warnings generated during test collection are reported.")


@pytest.mark.xfail
def test_kill_xfail():
    os.kill(os.getpid(), signal.SIGKILL)  # causes pytest to report stdout and stderr


def test_kill():
    os.kill(os.getpid(), signal.SIGKILL)  # causes pytest to report stdout and stderr


@pytest.mark.xfail
def test_exception_xfail():
    sys.stdout.write("This stdout message should be hidden due to xfail.")
    sys.stderr.write("This stderr message should be hidden due to xfail.")
    raise Exception("This error is expected, but should be hidden due to xfail.")


def test_exception():
    sys.stdout.write("This stdout message should be reported since we're throwing an exception.")
    sys.stderr.write("This stderr message should be reported since we're throwing an exception.")
    raise Exception("This error is expected and should be visible.")


def test_warning():
    warnings.warn("This verifies that warnings generated at test time are reported.")


def test_passed():
    pass