diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..3c21aa6 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,34 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Test with pytest + run: | + pytest diff --git a/.gitignore b/.gitignore index e325cb9..c28d7aa 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,7 @@ _ReSharper.* *.resharper Ankh.NoLoad -.vs \ No newline at end of file +.vs + +.venv +__pycache__ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9b38853 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9377b80 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +cffi==1.16.0 +clr-loader==0.2.6 +pycparser==2.21 +pythonnet==3.0.3 diff --git a/tests/test_mainfunc.py b/tests/test_mainfunc.py new file mode 100644 index 0000000..1316e6c --- /dev/null +++ b/tests/test_mainfunc.py @@ -0,0 +1,10 @@ +import subprocess +import pytest + +def test_main_function(): + script_path = "matrixCalcMain.py" + expected_output = "Enter the size of the matrix: " + + result = subprocess.run(["python", script_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + assert result.stdout == expected_output