File: test_example_fail_in_thread.py

package info (click to toggle)
pytest-check 2.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 480 kB
  • sloc: python: 2,220; sh: 17; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 450 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from concurrent.futures.thread import ThreadPoolExecutor
from threading import Thread


from pytest_check import check


def force_fail(comparison):
    check.equal(1 + 1, comparison, f"1 + 1 is 2, not {comparison}")


def test_threadpool():
    with ThreadPoolExecutor() as executor:
        task = executor.submit(force_fail, 3)
        task.result()


def test_threading():
    t = Thread(target=force_fail, args=(4, ))
    t.start()
    t.join()