MCPcopy Create free account
hub / github.com/apache/arrow / check_env_var

Function check_env_var

python/pyarrow/tests/test_memory.py:129–154  ·  view source on GitHub ↗
(name, expected, *, expect_warning=False)

Source from the content-addressed store, hash-verified

127
128
129def check_env_var(name, expected, *, expect_warning=False):
130 code = f"""if 1:
131 import pyarrow as pa
132
133 pool = pa.default_memory_pool()
134 assert pool.backend_name in {expected!r}, pool.backend_name
135 """
136 env = dict(os.environ)
137 env['ARROW_DEFAULT_MEMORY_POOL'] = name
138 res = subprocess.run([sys.executable, "-c", code], env=env,
139 universal_newlines=True, stderr=subprocess.PIPE)
140 if res.returncode != 0:
141 print(res.stderr, file=sys.stderr)
142 res.check_returncode() # fail
143 errlines = res.stderr.splitlines()
144 if expect_warning:
145 assert len(errlines) in (1, 2)
146 if len(errlines) == 1:
147 # ARROW_USE_GLOG=OFF
148 assert f"Unsupported backend '{name}'" in errlines[0]
149 else:
150 # ARROW_USE_GLOG=ON
151 assert "InitGoogleLogging()" in errlines[0]
152 assert f"Unsupported backend '{name}'" in errlines[1]
153 else:
154 assert len(errlines) == 0
155
156
157def test_env_var():

Callers 1

test_env_varFunction · 0.85

Calls 3

lenFunction · 0.85
check_returncodeMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected