Skip to content

Commit 316ca2c

Browse files
authoredNov 12, 2021
Simplify unit test runner (ansible-collections#309)
1 parent 55653aa commit 316ca2c

File tree

6 files changed

+29
-24
lines changed

6 files changed

+29
-24
lines changed
 

‎.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,3 @@ changelogs/.plugin-cache.yaml
391391

392392
# ansible-test ignores
393393
tests/integration/inventory*
394-
395-
396-
# VSCode
397-
.vscode/

‎.vscode/.env

-3
This file was deleted.

‎.vscode/extensions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"ms-python.python",
4+
"ms-vscode.powershell",
5+
]
6+
}

‎.vscode/settings.json

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
{
2-
"python.envFile": "${workspaceFolder}/.vscode/.env",
32
"python.testing.pytestArgs": [
4-
"-p", "pytest_collection_loader",
53
"tests/unit",
64
"-vv"
75
],
86
"python.testing.unittestEnabled": false,
9-
"python.testing.nosetestsEnabled": false,
107
"python.testing.pytestEnabled": true,
118
"python.analysis.extraPaths": [
12-
// ansible_collections dir
139
"${workspaceFolder}/../../../",
14-
// optional - ansible source checkout (points to the lib folder in the checkout)
15-
// "/home/<username>/ansible/lib",
16-
]
10+
],
11+
12+
"powershell.codeFormatting.addWhitespaceAroundPipe": true,
13+
"powershell.codeFormatting.alignPropertyValuePairs": false,
14+
"powershell.codeFormatting.autoCorrectAliases": true,
15+
"powershell.codeFormatting.ignoreOneLineBlock": true,
16+
"powershell.codeFormatting.newLineAfterCloseBrace": true,
17+
"powershell.codeFormatting.newLineAfterOpenBrace": true,
18+
"powershell.codeFormatting.openBraceOnSameLine": true,
19+
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
20+
"powershell.codeFormatting.whitespaceAfterSeparator": true,
21+
"powershell.codeFormatting.whitespaceAroundOperator": true,
22+
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
23+
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
24+
"powershell.codeFormatting.whitespaceBetweenParameters": true,
25+
"powershell.codeFormatting.whitespaceInsideBrace": true,
26+
"powershell.scriptAnalysis.enable": true,
27+
"[powershell]": {
28+
"editor.formatOnSave": true,
29+
},
1730
}

‎tests/utils/plugins/pytest_collection_loader.py renamed to ‎tests/unit/conftest.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
import os
66
import os.path
7-
import sys
87

8+
from ansible.utils.collection_loader._collection_finder import _AnsibleCollectionFinder
99

10-
ANSIBLE_COLLECTIONS_PATH = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..', '..', '..'))
10+
11+
ANSIBLE_COLLECTIONS_PATH = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..', '..'))
1112

1213

1314
# this monkeypatch to _pytest.pathlib.resolve_package_path fixes PEP420 resolution for collections in pytest >= 6.0.0
@@ -29,14 +30,6 @@ def pytest_configure():
2930
except AttributeError:
3031
pytest_configure.executed = True
3132

32-
# If ANSIBLE_HOME is set make sure we add it to the PYTHONPATH to ensure it is picked up. Not all env vars are
33-
# picked up by vscode (.bashrc is a notable one) so a user can define it manually in their .env file.
34-
ansible_home = os.environ.get('ANSIBLE_HOME', None)
35-
if ansible_home:
36-
sys.path.insert(0, os.path.join(ansible_home, 'lib'))
37-
38-
from ansible.utils.collection_loader._collection_finder import _AnsibleCollectionFinder
39-
4033
# allow unit tests to import code from collections
4134

4235
# noinspection PyProtectedMember

‎tests/utils/plugins/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)
Please sign in to comment.