[7.x] Test typing metadata in build-dist script

This commit is contained in:
Seth Michael Larson
2020-10-20 15:22:43 -05:00
committed by Seth Michael Larson
parent 0cdeeb654a
commit 2ce9fd3914
7 changed files with 235 additions and 4 deletions
+33 -1
View File
@@ -66,7 +66,7 @@ def test_dist(dist):
# Build the venv and install the dist
run("python", "-m", "venv", os.path.join(tmp_dir, "venv"))
venv_python = os.path.join(tmp_dir, "venv/bin/python")
run(venv_python, "-m", "pip", "install", "-U", "pip")
run(venv_python, "-m", "pip", "install", "-U", "pip", "mypy")
run(venv_python, "-m", "pip", "install", dist)
# Test the sync namespaces
@@ -106,6 +106,17 @@ def test_dist(dist):
f"from {dist_name}.helpers import async_scan, async_bulk, async_streaming_bulk, async_reindex",
)
# Only need to test 'async_types' for non-aliased package
# since 'aliased_types' tests both async and sync.
if dist_name == "elasticsearch":
run(
venv_python,
"-m",
"mypy",
"--strict",
os.path.join(base_dir, "test_elasticsearch/test_types/async_types.py"),
)
# Ensure that the namespaces are correct for the dist
for suffix in ("", "1", "2", "5", "6", "7", "8", "9", "10"):
distx_name = f"elasticsearch{suffix}"
@@ -116,6 +127,27 @@ def test_dist(dist):
expect_exit_code=256 if distx_name != dist_name else 0,
)
# Check that sync types work for 'elasticsearch' and
# that aliased types work for 'elasticsearchX'
if dist_name == "elasticsearch":
run(
venv_python,
"-m",
"mypy",
"--strict",
os.path.join(base_dir, "test_elasticsearch/test_types/sync_types.py"),
)
else:
run(
venv_python,
"-m",
"mypy",
"--strict",
os.path.join(
base_dir, "test_elasticsearch/test_types/aliased_types.py"
),
)
# Uninstall the dist, see that we can't import things anymore
run(venv_python, "-m", "pip", "uninstall", "--yes", dist_name)
run(