Skip to content

Backport PR #45812 on branch 1.4.x (TST: Create is_ci_environment helper) #45823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Other items:
* platform checker
"""
import os
import platform
import sys

Expand Down Expand Up @@ -89,7 +90,7 @@ def is_platform_mac() -> bool:

def is_platform_arm() -> bool:
"""
Checking if he running platform use ARM architecture.
Checking if the running platform use ARM architecture.

Returns
-------
Expand All @@ -101,6 +102,19 @@ def is_platform_arm() -> bool:
)


def is_ci_environment() -> bool:
"""
Checking if running in a continuous integration environment by checking
the PANDAS_CI environment variable.

Returns
-------
bool
True if the running in a continuous integration environment.
"""
return os.environ.get("PANDAS_CI", "0") == "1"


def get_lzma_file():
"""
Importing the `LZMAFile` class from the `lzma` module.
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/io/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from pandas.compat import (
is_ci_environment,
is_platform_arm,
is_platform_mac,
is_platform_windows,
Expand Down Expand Up @@ -42,7 +43,7 @@ def feather_file(datapath):

@pytest.fixture
def s3so(worker_id):
if os.environ.get("PANDAS_CI", "0") == "1":
if is_ci_environment():
url = "http://localhost:5000/"
else:
worker_id = "5" if worker_id == "master" else worker_id.lstrip("gw")
Expand All @@ -66,7 +67,7 @@ def s3_base(worker_id):
# see https://github.com/spulec/moto/issues/1924 & 1952
os.environ.setdefault("AWS_ACCESS_KEY_ID", "foobar_key")
os.environ.setdefault("AWS_SECRET_ACCESS_KEY", "foobar_secret")
if os.environ.get("PANDAS_CI", "0") == "1":
if is_ci_environment():
if is_platform_arm() or is_platform_mac() or is_platform_windows():
# NOT RUN on Windows/MacOS/ARM, only Ubuntu
# - subprocess in CI can cause timeouts
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/parser/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
StringIO,
)
import logging
import os

import numpy as np
import pytest

from pandas.compat import is_ci_environment
import pandas.util._test_decorators as td

from pandas import DataFrame
Expand Down Expand Up @@ -258,7 +258,7 @@ def test_read_csv_handles_boto_s3_object(self, s3_resource, tips_file):
tm.assert_frame_equal(result, expected)

@pytest.mark.skipif(
os.environ.get("PANDAS_CI", "0") == "1",
is_ci_environment(),
reason="This test can hang in our CI min_versions build "
"and leads to '##[error]The runner has "
"received a shutdown signal...' in GHA. GH: 45651",
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/test_user_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import http.server
from io import BytesIO
import multiprocessing
import os
import socket
import time
import urllib.error

import pytest

from pandas.compat import is_ci_environment
import pandas.util._test_decorators as td

import pandas as pd
import pandas._testing as tm

pytestmark = pytest.mark.skipif(
os.environ.get("PANDAS_CI", "0") == "1",
is_ci_environment(),
reason="This test can hang in our CI min_versions build "
"and leads to '##[error]The runner has "
"received a shutdown signal...' in GHA. GH 45651",
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import pytest

from pandas.compat import is_ci_environment
from pandas.compat._optional import import_optional_dependency
import pandas.util._test_decorators as td

Expand Down Expand Up @@ -1107,7 +1108,7 @@ def test_unsuported_compression(datapath, parser):
@td.skip_if_no("s3fs")
@td.skip_if_no("lxml")
@pytest.mark.skipif(
os.environ.get("PANDAS_CI", "0") == "1",
is_ci_environment(),
reason="2022.1.17: Hanging on the CI min versions build.",
)
@tm.network
Expand Down
8 changes: 5 additions & 3 deletions pandas/tests/test_sorting.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from collections import defaultdict
from datetime import datetime
from itertools import product
import os

import numpy as np
import pytest

from pandas.compat import is_platform_windows
from pandas.compat import (
is_ci_environment,
is_platform_windows,
)

from pandas import (
DataFrame,
Expand Down Expand Up @@ -428,7 +430,7 @@ def test_codes(self, verify, codes, exp_codes, na_sentinel):
tm.assert_numpy_array_equal(result_codes, expected_codes)

@pytest.mark.skipif(
is_platform_windows() and os.environ.get("PANDAS_CI", "0") == "1",
is_platform_windows() and is_ci_environment(),
reason="In CI environment can crash thread with: "
"Windows fatal exception: access violation",
)
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/window/test_numba.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os

import numpy as np
import pytest

from pandas.compat import (
is_ci_environment,
is_platform_mac,
is_platform_windows,
)
Expand All @@ -21,8 +20,7 @@

# TODO(GH#44584): Mark these as pytest.mark.single
pytestmark = pytest.mark.skipif(
os.environ.get("PANDAS_CI", "0") == "1"
and (is_platform_windows() or is_platform_mac()),
is_ci_environment() and (is_platform_windows() or is_platform_mac()),
reason="On Azure CI, Windows can fail with "
"'Windows fatal exception: stack overflow' "
"and MacOS can timeout",
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/window/test_online.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os

import numpy as np
import pytest

from pandas.compat import (
is_ci_environment,
is_platform_mac,
is_platform_windows,
)
Expand All @@ -17,8 +16,7 @@

# TODO(GH#44584): Mark these as pytest.mark.single
pytestmark = pytest.mark.skipif(
os.environ.get("PANDAS_CI", "0") == "1"
and (is_platform_windows() or is_platform_mac()),
is_ci_environment() and (is_platform_windows() or is_platform_mac()),
reason="On Azure CI, Windows can fail with "
"'Windows fatal exception: stack overflow' "
"and MacOS can timeout",
Expand Down