File: test_filter_subpackage.py

package info (click to toggle)
pytest-filter-subpackage 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: python: 149; makefile: 3
file content (61 lines) | stat: -rw-r--r-- 1,868 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
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
pytest_plugins = ['pytester']


def test_default(testdir, testpackage):
    # Make sure all code tests are picked up by default
    reprec = testdir.inline_run()
    reprec.assertoutcome(passed=5, failed=3)


def test_with_rst(testdir, testpackage):
    # Make sure all rst tests are also picked up when using pytest-doctestplus
    testdir.makeini("""
    [pytest]
    doctest_plus = enabled
    """)
    reprec = testdir.inline_run('--doctest-rst')
    reprec.assertoutcome(passed=7, failed=3)


def test_flag_single_subpackage(testdir, testpackage):
    # Test -P with a single sub-package
    reprec = testdir.inline_run('-P a')
    reprec.assertoutcome(passed=2, failed=0)


def test_flag_single_subpackage_with_rst(testdir, testpackage):
    # Test -P with a single sub-package including rst files
    testdir.makeini("""
    [pytest]
    doctest_plus = enabled
    """)
    reprec = testdir.inline_run('-P a', '--doctest-rst')
    reprec.assertoutcome(passed=3, failed=0)


def test_flag_multiple_subpackage(testdir, testpackage):
    # Test -P with several sub-packages
    reprec = testdir.inline_run('-P a,b')
    reprec.assertoutcome(passed=3, failed=1)


def test_flag_multiple_subpackage_with_rst(testdir, testpackage):
    # Test -P with several sub-packages including rst files
    testdir.makeini("""
    [pytest]
    doctest_plus = enabled
    """)
    reprec = testdir.inline_run('-P a,b', '--doctest-rst')
    reprec.assertoutcome(passed=4, failed=1)


def test_flag_single_subpackage_partial(testdir, testpackage):
    # Check that -P c will collect tests in c.d
    reprec = testdir.inline_run('-P c')
    reprec.assertoutcome(passed=2, failed=2)


def test_flag_single_subsubpackage(testdir, testpackage):
    # Check that -P c.d will not collect tests in c.
    reprec = testdir.inline_run('-P c.d')
    reprec.assertoutcome(passed=1, failed=1)