File: test_runner.py

package info (click to toggle)
pytest-django 4.11.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 604 kB
  • sloc: python: 4,006; makefile: 39; sh: 17
file content (26 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
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
from unittest.mock import Mock, call

import pytest

from pytest_django.runner import TestRunner


@pytest.mark.parametrize(
    "kwargs, expected",
    [
        ({}, call(["tests"])),
        ({"verbosity": 0}, call(["--quiet", "tests"])),
        ({"verbosity": 1}, call(["tests"])),
        ({"verbosity": 2}, call(["-v", "tests"])),
        ({"verbosity": 3}, call(["-vv", "tests"])),
        ({"verbosity": 4}, call(["-vvv", "tests"])),
        ({"failfast": True}, call(["--exitfirst", "tests"])),
        ({"keepdb": True}, call(["--reuse-db", "tests"])),
    ],
)
def test_runner_run_tests(monkeypatch, kwargs, expected):
    pytest_mock = Mock()
    monkeypatch.setattr("pytest.main", pytest_mock)
    runner = TestRunner(**kwargs)
    runner.run_tests(["tests"])
    assert pytest_mock.call_args == expected