2
2
# Licensed under the MIT License.
3
3
import json
4
4
import os
5
+ import subprocess
5
6
import sys
6
7
from typing import Any , Dict , List , Optional
7
8
12
13
from . import expected_discovery_test_output , helpers # noqa: E402
13
14
14
15
16
+ @pytest .fixture
17
+ def pluggy_version_resource_setup_teardown ():
18
+ # Setup to switch plugin versions
19
+ subprocess .run (["pip" , "install" , "pluggy==1.1.0" ])
20
+ yield
21
+ # switch back to a newer version
22
+ subprocess .run (["pip" , "install" , "pluggy==1.2.0" ])
23
+ print ("Tearing down pluggy version" )
24
+
25
+
26
+ def test_pluggy_old_version (pluggy_version_resource_setup_teardown ):
27
+ print ("Running test_example" )
28
+ try :
29
+ helpers .runner (
30
+ [
31
+ os .fspath (helpers .TEST_DATA_PATH / "simple_pytest.py" ),
32
+ "--collect-only" ,
33
+ ]
34
+ )
35
+ assert True
36
+ except Exception as e :
37
+ print (f"Exception: { e } " )
38
+ assert False
39
+ # If an error or assertion failure occurs above, the teardown will still execute.
40
+
41
+
15
42
def test_import_error ():
16
43
"""Test pytest discovery on a file that has a pytest marker but does not import pytest.
17
44
@@ -23,6 +50,7 @@ def test_import_error():
23
50
Keyword arguments:
24
51
tmp_path -- pytest fixture that creates a temporary directory.
25
52
"""
53
+ subprocess .run (["pip" , "install" , "pluggy==1.1.0" ])
26
54
file_path = helpers .TEST_DATA_PATH / "error_pytest_import.txt"
27
55
with helpers .text_to_python_file (file_path ) as p :
28
56
actual : Optional [List [Dict [str , Any ]]] = helpers .runner (["--collect-only" , os .fspath (p )])
0 commit comments