@@ -59,7 +59,6 @@ def pytest_addoption(parser):
5959
6060def pytest_collection_modifyitems (config , items ):
6161 if config .getoption ("--ignore_v20_test" ):
62- # --ignore_v20_test given in cli: skip sqlalchemy 2.0 tests
6362 skip_feature_v2 = pytest .mark .skip (
6463 reason = "need remove --ignore_v20_test option to run"
6564 )
@@ -68,35 +67,6 @@ def pytest_collection_modifyitems(config, items):
6867 item .add_marker (skip_feature_v2 )
6968
7069
71- @pytest .fixture (scope = "session" )
72- def on_travis ():
73- return os .getenv ("TRAVIS" , "" ).lower () == "true"
74-
75-
76- @pytest .fixture (scope = "session" )
77- def on_appveyor ():
78- return os .getenv ("APPVEYOR" , "" ).lower () == "true"
79-
80-
81- @pytest .fixture (scope = "session" )
82- def on_public_ci (on_travis , on_appveyor ):
83- return on_travis or on_appveyor
84-
85-
86- def help ():
87- print (
88- """Connection parameter must be specified in parameters.py,
89- for example:
90- CONNECTION_PARAMETERS = {
91- 'account': 'testaccount',
92- 'user': 'user1',
93- 'password': 'test',
94- 'database': 'testdb',
95- 'schema': 'public',
96- }"""
97- )
98-
99-
10070logger = getLogger (__name__ )
10171
10272TZ_ENV_VAR : Literal ["TZ" ] = "TZ"
@@ -137,6 +107,11 @@ def external_stage():
137107 raise ValueError ("External_stage is not set" )
138108
139109
110+ @pytest .fixture (scope = "session" )
111+ def on_public_ci ():
112+ return running_on_public_ci ()
113+
114+
140115@pytest .fixture (scope = "function" )
141116def base_location (external_stage , engine_testaccount ):
142117 unique_id = str (uuid .uuid4 ())
@@ -325,6 +300,7 @@ def running_on_public_ci() -> bool:
325300
326301def pytest_runtest_setup (item ) -> None :
327302 """Ran before calling each test, used to decide whether a test should be skipped."""
303+ _ensure_optional_dependencies (item )
328304 test_tags = [mark .name for mark in item .iter_markers ()]
329305
330306 # Get what cloud providers the test is marked for if any
@@ -342,3 +318,9 @@ def pytest_runtest_setup(item) -> None:
342318 pytest .skip ("cannot run this test on external CI" )
343319 elif INTERNAL_SKIP_TAGS .intersection (test_tags ) and not running_on_public_ci ():
344320 pytest .skip ("cannot run this test on internal CI" )
321+
322+
323+ def _ensure_optional_dependencies (item ):
324+ """Skip optional-dependency tests when the dependency is unavailable."""
325+ if "pandas" in item .keywords :
326+ pytest .importorskip ("pandas" )
0 commit comments