File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ import textwrap
2+
3+ import pytest
4+
5+ import _pytest .pytester
6+
7+
8+ def test_plugin (
9+ pytester : _pytest .pytester .Pytester ,
10+ monkeypatch : pytest .MonkeyPatch ,
11+ ) -> None :
12+ # Initialize variables
13+ pytester .plugins = ["pytest_plugin" ]
14+ pytester .makefile (
15+ ".ini" ,
16+ pytest = textwrap .dedent (
17+ """
18+ [pytest]
19+ addopts=-vv
20+ """ .strip ()
21+ ),
22+ )
23+ pytester .makeconftest (
24+ textwrap .dedent (
25+ r"""
26+ import pathlib
27+ import pytest
28+
29+ @pytest.fixture(autouse=True)
30+ def setup(
31+ request: pytest.FixtureRequest,
32+ ) -> None:
33+ pass
34+ """
35+ )
36+ )
37+ tests_path = pytester .path / "tests"
38+ files = {
39+ "example.py" : textwrap .dedent (
40+ """
41+ import pathlib
42+
43+ def test_repo_git_remote_checkout(
44+ session,
45+ ) -> None:
46+ assert session.name is not None
47+
48+ assert session._session_id == "$1"
49+
50+ new_window = session.new_window(attach=False, window_name="my window name")
51+ assert new_window.name == "my window name"
52+ """
53+ )
54+ }
55+ first_test_key = list (files .keys ())[0 ]
56+ first_test_filename = str (tests_path / first_test_key )
57+
58+ # Setup: Files
59+ tests_path .mkdir ()
60+ for file_name , text in files .items ():
61+ test_file = tests_path / file_name
62+ test_file .write_text (
63+ text ,
64+ encoding = "utf-8" ,
65+ )
66+
67+ # Test
68+ result = pytester .runpytest (str (first_test_filename ))
69+ result .assert_outcomes (passed = 1 )
You can’t perform that action at this time.
0 commit comments