Skip to content
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

Add Test Environment that runs tests w/out aiohttp #17718

Merged
merged 7 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ jobs:
- pwsh: |
$toxenvvar = "whl,sdist"
if ('$(System.TeamProject)' -eq 'internal') {
$toxenvvar = "whl,sdist,depends,latestdependency,mindependency"
$toxenvvar = "whl,sdist,depends,latestdependency,mindependency,whl_no_aio"
}

# ensure that the variable is unset. if it isn't, use the value discovered there
Expand Down
18 changes: 18 additions & 0 deletions eng/tox/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ commands =
{envbindir}/python {toxinidir}/../../../eng/tox/run_mypy.py -t {toxinidir}


[testenv:whl_no_aio]
skipsdist = true
skip_install = true
changedir = {toxinidir}
deps =
{[base]deps}
commands =
- {envbindir}/python -m pip uninstall aiohttp --yes
{envbindir}/python {toxinidir}/../../../eng/tox/create_package_and_install.py -d {envtmpdir} -p {toxinidir} -w {envtmpdir}
{envbindir}/python {toxinidir}/../../../eng/tox/try_import.py aiohttp
{envbindir}/python -m pip freeze
pytest \
{[testenv]default_pytest_params} \
--ignore-glob='*_async.py' \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having this means that async tests implode with

image

{posargs} \
{toxinidir}


[testenv:sdist]
skipsdist = true
skip_install = true
Expand Down
52 changes: 52 additions & 0 deletions eng/tox/try_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python

# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# This script is used to execute bandit within a tox environment. Depending on which package is being executed against,
# a failure may be suppressed.


from subprocess import check_call, CalledProcessError
import argparse
import os
import logging
import sys
import pdb

logging.getLogger().setLevel(logging.INFO)

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Ensures that an environment doesn't have specific packages."
)

parser.add_argument(
"imports",
metavar="N",
type=str,
nargs="+",
help="an integer for the accumulator",
)

args = parser.parse_args()

print(args.imports)

importable_packages = []

for ns in list(args.imports):
try:
logging.info("Ensuring that namespace {} is not importable.".format(ns))
exec("import {}".format(ns))
importable_packages.append(ns)
except ImportError:
logging.info("Hit expected import error against {}".format(ns))
pass

if importable_packages:
raise Exception(
"Was erroneously able to import from {}".format(importable_packages)
)