-
Notifications
You must be signed in to change notification settings - Fork 265
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
Improve unit tests. #270
Open
badcure
wants to merge
6
commits into
diyan:master
Choose a base branch
from
badcure:add_tox_testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Improve unit tests. #270
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d0af0a1
Moving to requirements files, and setting up tox for local testing.
badcure 4d4885c
Setting up parent testing class, and fixing some bugs with the changes.
badcure 8652a95
Fixing a bug with installs.
badcure 862abbd
Setting up parent testing class, and fixing some bugs with the changes.
badcure acf14b3
Fixing the CredSSP and Kerberos testing once again.
badcure f6913d4
Started mocking the request and responses from winrm.
badcure File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ __pycache__ | |
/winrm/tests/config.json | ||
.pytest_cache | ||
venv | ||
.tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ pytest==4.4.2 | |
pytest-cov==2.7.1 | ||
pytest-flake8==1.0.4 | ||
mock==3.0.5 | ||
requests_mock==1.5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
xmltodict | ||
requests>=2.9.1 | ||
requests_ntlm>=0.3.0 | ||
six>=1.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests-credssp>=1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
winkerberos>=0.5.0 ; sys_platform=="win32" | ||
pykerberos>=1.2.1,<2.0.0 ; sys_platform!="win32" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
xmltodict==0.3.0 | ||
requests==2.9.1 | ||
requests_ntlm==0.3.0 | ||
six==1.7.0 | ||
|
||
# credssp | ||
requests-credssp==1.0.0 | ||
|
||
# kerberos | ||
winkerberos==0.5.0 ; sys_platform=="win32" | ||
pykerberos==1.2.1 ; sys_platform!="win32" | ||
|
||
-r ../requirements-test.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[tox] | ||
envlist = py27,py35,py36,py37,py38,py27min,py37min,py27base,py37base | ||
skip_missing_interpreters = True | ||
skipsdist = True | ||
sitepackages = False | ||
|
||
[testenv] | ||
ignore_errors = False | ||
deps = | ||
-r{toxinidir}/requirements-test.txt | ||
-r{toxinidir}/requirements/extras/requirements-credssp.txt | ||
-r{toxinidir}/requirements/extras/requirements-kerberos.txt | ||
-r{toxinidir}/requirements.txt | ||
setenv = | ||
PYWINRM_TEST_CREDSSP=1 | ||
PYWINRM_TEST_KERBEROS=1 | ||
commands = | ||
pytest -v --flake8 --cov=winrm --cov-report=term-missing winrm/tests/ | ||
whitelist_externals = bash | ||
|
||
# Test the base install, without extras. | ||
[testenv:py27base] | ||
ignore_errors = False | ||
deps = | ||
-r{toxinidir}/requirements-test.txt | ||
-r{toxinidir}/requirements.txt | ||
setenv = | ||
PYWINRM_TEST_CREDSSP=0 | ||
PYWINRM_TEST_KERBEROS=0 | ||
commands = | ||
pytest -v --flake8 --cov=winrm --cov-report=term-missing winrm/tests/ | ||
whitelist_externals = bash | ||
|
||
[testenv:py37base] | ||
ignore_errors = False | ||
deps = | ||
-r{toxinidir}/requirements-test.txt | ||
-r{toxinidir}/requirements.txt | ||
setenv = | ||
PYWINRM_TEST_CREDSSP=0 | ||
PYWINRM_TEST_KERBEROS=0 | ||
commands = | ||
pytest -v --flake8 --cov=winrm --cov-report=term-missing winrm/tests/ | ||
whitelist_externals = bash | ||
|
||
# Test the minimum requirements for the packages. | ||
[testenv:py27min] | ||
ignore_errors = False | ||
deps = | ||
-r{toxinidir}/requirements/requirements-testmin.txt | ||
setenv = | ||
PYWINRM_TEST_CREDSSP=1 | ||
PYWINRM_TEST_KERBEROS=1 | ||
commands = | ||
pytest -v --flake8 --cov=winrm --cov-report=term-missing winrm/tests/ | ||
whitelist_externals = bash | ||
|
||
[testenv:py37min] | ||
ignore_errors = False | ||
deps = | ||
-r{toxinidir}/requirements/requirements-testmin.txt | ||
setenv = | ||
PYWINRM_TEST_CREDSSP=1 | ||
PYWINRM_TEST_KERBEROS=1 | ||
commands = | ||
pytest -v --flake8 --cov=winrm --cov-report=term-missing winrm/tests/ | ||
whitelist_externals = bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import unittest | ||
import requests_mock | ||
from winrm import transport | ||
|
||
if os.environ.get('PYWINRM_TEST_CREDSSP') == '1': | ||
EXPECT_CREDSSP = True | ||
elif os.environ.get('PYWINRM_TEST_CREDSSP') == '0': | ||
EXPECT_CREDSSP = False | ||
else: | ||
EXPECT_CREDSSP = transport.HAVE_CREDSSP | ||
|
||
if os.environ.get('PYWINRM_TEST_KERBEROS') == '1': | ||
EXPECT_KERBEROS = True | ||
elif os.environ.get('PYWINRM_TEST_KERBEROS') == '0': | ||
EXPECT_KERBEROS = False | ||
else: | ||
EXPECT_KERBEROS = transport.HAVE_KERBEROS | ||
|
||
|
||
class BaseTest(unittest.TestCase): | ||
maxDiff = 2048 | ||
_old_env = None | ||
|
||
def setUp(self): | ||
super(BaseTest, self).setUp() | ||
self.mocked_request = requests_mock.Mocker() | ||
self.mocked_request.start() | ||
self._old_env = {} | ||
os.environ.pop('REQUESTS_CA_BUNDLE', None) | ||
os.environ.pop('TRAVIS_APT_PROXY', None) | ||
os.environ.pop('CURL_CA_BUNDLE', None) | ||
os.environ.pop('HTTPS_PROXY', None) | ||
os.environ.pop('HTTP_PROXY', None) | ||
os.environ.pop('NO_PROXY', None) | ||
|
||
def tearDown(self): | ||
super(BaseTest, self).tearDown() | ||
os.environ.pop('REQUESTS_CA_BUNDLE', None) | ||
os.environ.pop('TRAVIS_APT_PROXY', None) | ||
os.environ.pop('CURL_CA_BUNDLE', None) | ||
os.environ.pop('HTTPS_PROXY', None) | ||
os.environ.pop('HTTP_PROXY', None) | ||
os.environ.pop('NO_PROXY', None) | ||
self.mocked_request.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't do this, tox can use the extras and install_requires, just make sure to set `skipsdist = False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then you can do: