File: test_check_test_naming.py

package info (click to toggle)
pandas 2.2.3%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,784 kB
  • sloc: python: 422,228; ansic: 9,190; sh: 270; xml: 102; makefile: 83
file content (43 lines) | stat: -rw-r--r-- 1,217 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pytest

from scripts.check_test_naming import main


@pytest.mark.parametrize(
    "src, expected_out, expected_ret",
    [
        (
            "def foo(): pass\n",
            "t.py:1:0 found test function which does not start with 'test'\n",
            1,
        ),
        (
            "class Foo:\n    def test_foo(): pass\n",
            "t.py:1:0 found test class which does not start with 'Test'\n",
            1,
        ),
        ("def test_foo(): pass\n", "", 0),
        ("class TestFoo:\n    def test_foo(): pass\n", "", 0),
        (
            "def foo():\n    pass\ndef test_foo():\n    foo()\n",
            "",
            0,
        ),
        (
            "class Foo:  # not a test\n"
            "    pass\n"
            "def test_foo():\n"
            "    Class.foo()\n",
            "",
            0,
        ),
        ("@pytest.fixture\ndef foo(): pass\n", "", 0),
        ("@pytest.fixture()\ndef foo(): pass\n", "", 0),
        ("@register_extension_dtype\nclass Foo: pass\n", "", 0),
    ],
)
def test_main(capsys, src, expected_out, expected_ret):
    ret = main(src, "t.py")
    out, _ = capsys.readouterr()
    assert out == expected_out
    assert ret == expected_ret