diff --git a/.vscode/settings.json b/.vscode/settings.json index b035bb43d..efe0b9062 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,13 @@ { - "python.pythonPath": "${workspaceFolder}\\env\\Scripts\\python.exe" + "python.pythonPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Anaconda3_64\\python.exe", + "python.testing.unittestArgs": [ + "-v", + "-s", + ".", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.nosetestsEnabled": false, + "python.testing.unittestEnabled": true } \ No newline at end of file diff --git a/README.md b/README.md index d07d6d8ed..bad955ab9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Python/Flask tutorial sample for Visual Studio Code +[![Build Status](https://dev.azure.com/adambdevops/adambdevops/_apis/build/status/adambdevops.python-sample-vscode-flask-tutorial?branchName=master)](https://dev.azure.com/adambdevops/adambdevops/_build/latest?definitionId=2&branchName=master) + * This sample contains the completed program from the tutorial, make sure to visit the link: [Using Flask in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-flask). Intermediate steps are not included. * It also contains the Dockerfile and uwsgi.ini files necessary to build a container with a production server. The resulting image works both locally and when deployed to Azure App Service. See [Deploy Python using Docker containers](https://code.visualstudio.com/docs/python/tutorial-deploy-containers). diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..3b433946c --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,33 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +pool: + vmImage: 'ubuntu-latest' +strategy: + matrix: + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: | + pip install pytest + pip install pytest-cov + pytest -k 'test_' --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + displayName: 'Test with pytest' diff --git a/hello_app/helloworld.py b/hello_app/helloworld.py new file mode 100644 index 000000000..a72f5f8be --- /dev/null +++ b/hello_app/helloworld.py @@ -0,0 +1,7 @@ +class helloWorld(): + def __init__(self): + pass + + def hello_world(self, person_name=None): + + return f"Hello {person_name}" \ No newline at end of file diff --git a/hello_app/test_helloworld.py b/hello_app/test_helloworld.py new file mode 100644 index 000000000..c09550e19 --- /dev/null +++ b/hello_app/test_helloworld.py @@ -0,0 +1,10 @@ +import unittest +from .helloworld import helloWorld + +class TestHelloWorldMethods(unittest.TestCase): + + def test_helloworld(self): + self.assertEqual(helloWorld.hello_world(self, "adam"), 'Hello adam') + +if __name__ == "__main__": + unittest.main() \ No newline at end of file