File: test_qthreadexec.py

package info (click to toggle)
python-quamash 0.6.1~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 204 kB
  • sloc: python: 1,290; sh: 4; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 732 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# © 2014 Mark Harviston <mark.harviston@gmail.com>
# © 2014 Arve Knudsen <arve.knudsen@gmail.com>
# BSD License
import pytest
import quamash


@pytest.fixture
def executor(request):
	exe = quamash.QThreadExecutor(5)
	request.addfinalizer(exe.shutdown)
	return exe


@pytest.fixture
def shutdown_executor():
	exe = quamash.QThreadExecutor(5)
	exe.shutdown()
	return exe


def test_shutdown_after_shutdown(shutdown_executor):
	with pytest.raises(RuntimeError):
		shutdown_executor.shutdown()


def test_ctx_after_shutdown(shutdown_executor):
	with pytest.raises(RuntimeError):
		with shutdown_executor:
			pass


def test_submit_after_shutdown(shutdown_executor):
	with pytest.raises(RuntimeError):
		shutdown_executor.submit(None)