Run test in isolation. Helper utility for invoking scripts that need to be run in isolation

This commit is contained in:
Wes McKinney committed 2020-03-05 19:25:23 -06:00
1 parent a022026532
commit a32e2047ea
4 files changed
+50 -13

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# This file is called from a test in test_schema.py.
import pyarrow as pa
# the types where to_pandas_dtype returns a non-numpy dtype
cases = [
(pa.timestamp('ns', tz='UTC'), "datetime64[ns, UTC]"),
]
for arrow_type, pandas_type in cases:
assert str(arrow_type.to_pandas_dtype()) == pandas_type
+5 -7
View File
@@ -23,6 +23,8 @@ import pytest
import numpy as np
import pyarrow as pa
import pyarrow.tests.util as test_util
def test_schema_constructor_errors():
msg = ("Do not call Schema's constructor directly, use `pyarrow.schema` "
@@ -71,13 +73,9 @@ def test_type_to_pandas_dtype():
@pytest.mark.pandas
def test_type_to_pandas_dtype2():
# the types where to_pandas_dtype returns a non-numpy dtype
cases = [
(pa.timestamp('ns', tz='UTC'), "datetime64[ns, UTC]"),
]
for arrow_type, pandas_type in cases:
assert str(arrow_type.to_pandas_dtype()) == pandas_type
def test_type_to_pandas_dtype_check_import():
# ARROW-7980
test_util.invoke_script('arrow_7980.py')
def test_type_list():
+1 -6
View File
@@ -952,12 +952,7 @@ def test_deserialize_buffer_in_different_process():
f.write(b.to_pybytes())
f.close()
subprocess_env = test_util.get_modified_env_with_pythonpath()
dir_path = os.path.dirname(os.path.realpath(__file__))
python_file = os.path.join(dir_path, 'deserialize_buffer.py')
subprocess.check_call([sys.executable, python_file, f.name],
env=subprocess_env)
test_util.invoke_script('deserialize_buffer.py', f.name)
def test_set_pickle():
+14
View File
@@ -25,6 +25,8 @@ import numpy as np
import os
import random
import string
import subprocess
import sys
import pyarrow as pa
@@ -136,3 +138,15 @@ def get_modified_env_with_pythonpath():
new_pythonpath = module_path
env['PYTHONPATH'] = new_pythonpath
return env
def invoke_script(script_name, *args):
subprocess_env = get_modified_env_with_pythonpath()
dir_path = os.path.dirname(os.path.realpath(__file__))
python_file = os.path.join(dir_path, script_name)
cmd = [sys.executable, python_file]
cmd.extend(args)
subprocess.check_call(cmd, env=subprocess_env)