[Python] Updates python test framework to pytest (#4765)

* Switches python generators to use pytest, useNose CLI option added if to allow nose to be used instead

* Adds ensure-up-to-date changes

* Adds setup.cfg to python clients so we can configure nose when useNose=true

* Adds fix for python-aiohttp testing, adds files missing from ensure-up-to-date
This commit is contained in:
Justin Black
2019-12-22 00:14:04 -06:00
committed by William Cheng
parent 1084cd38a1
commit 3959530465
96 changed files with 385 additions and 188 deletions

View File

@@ -45,7 +45,9 @@ coverage.xml
*,cover
.hypothesis/
venv/
.venv/
.python-version
.pytest_cache
# Translations
*.mo

View File

@@ -1,5 +1,2 @@
nose
tox
coverage
randomize
flake8

View File

@@ -27,7 +27,7 @@
<version>1.2.1</version>
<executions>
<execution>
<id>nose-test</id>
<id>test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>

View File

@@ -1,11 +1,2 @@
[nosetests]
logging-clear-handlers=true
verbosity=2
randomize=true
exe=true
with-coverage=true
cover-package=petstore_api
cover-erase=true
[flake8]
max-line-length=99

View File

@@ -1,5 +1,3 @@
coverage>=4.0.3
nose>=1.3.7
pluggy>=0.3.1
py>=1.4.31
randomize>=0.13
pytest~=4.6.7 # needed for python 2.7+3.4
pytest-cov>=2.8.1
pytest-randomly==1.2.3 # needed for python 2.7+3.4

View File

@@ -11,17 +11,16 @@ export LANG=en_US.UTF-8
### set virtualenv
if [ -z "$VIRTUAL_ENV" ]; then
virtualenv $VENV --no-site-packages --always-copy
virtualenv $VENV --no-site-packages --always-copy --python python
source $VENV/bin/activate
DEACTIVE=true
fi
### install dependencies
pip install -r $REQUIREMENTS_FILE | tee -a $REQUIREMENTS_OUT
python setup.py develop
### run tests
nosetests || exit 1
tox -e py27 || exit 1
### static analysis of code
flake8 --show-source petstore_api/
@@ -30,4 +29,3 @@ flake8 --show-source petstore_api/
#if [ $DEACTIVE == true ]; then
# deactivate
#fi

View File

@@ -18,7 +18,6 @@ fi
### install dependencies
pip install -r $REQUIREMENTS_FILE | tee -a $REQUIREMENTS_OUT
python setup.py develop
### run tests
tox || exit 1

View File

@@ -157,7 +157,7 @@ class PetApiTests(unittest.TestCase):
response = thread.get()
response2 = thread2.get()
self.assertEquals(response.id, self.pet.id)
self.assertEqual(response.id, self.pet.id)
self.assertIsNotNone(response2.id, self.pet.id)
def test_async_with_http_info(self):
@@ -167,7 +167,7 @@ class PetApiTests(unittest.TestCase):
data, status, headers = thread.get()
self.assertIsInstance(data, petstore_api.Pet)
self.assertEquals(status, 200)
self.assertEqual(status, 200)
def test_async_exception(self):
self.pet_api.add_pet(self.pet)

View File

@@ -6,5 +6,4 @@ deps=-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands=
nosetests \
[]
pytest --cov=petstore_api