diff --git a/.pipelines/azdo-base-pipeline.yml b/.pipelines/azdo-base-pipeline.yml index ad0e4ad8..479596f1 100644 --- a/.pipelines/azdo-base-pipeline.yml +++ b/.pipelines/azdo-base-pipeline.yml @@ -1,7 +1,11 @@ steps: -- script: | - ./lint-and-test.sh - displayName: 'Linting & unit tests' +- script: | + flake8 --output-file=lint-testresults.xml --format junit-xml + displayName: 'Run lint tests' + +- script: | + python -m pytest . --cov=diabetes_regression --cov-report=html --cov-report=xml --junitxml=unit-testresults.xml + displayName: 'Run unit tests' - task: PublishTestResults@2 condition: succeededOrFailed() diff --git a/tests/unit/data_test.py b/data/data_test.py similarity index 98% rename from tests/unit/data_test.py rename to data/data_test.py index 4148f029..6d7d2ddf 100644 --- a/tests/unit/data_test.py +++ b/data/data_test.py @@ -35,7 +35,7 @@ def get_absPath(filename): path = os.path.abspath( os.path.join( os.path.dirname( - __file__), os.path.pardir, os.path.pardir, "data", filename + __file__), os.path.pardir, "data", filename ) ) return path diff --git a/diabetes_regression/ci_dependencies.yml b/diabetes_regression/ci_dependencies.yml index c5463456..d6a52ed0 100644 --- a/diabetes_regression/ci_dependencies.yml +++ b/diabetes_regression/ci_dependencies.yml @@ -25,4 +25,3 @@ dependencies: - flake8==3.7.9 - flake8_formatter_junit_xml==0.0.6 - azure-cli==2.0.81 - - tox==3.14.3 diff --git a/tests/unit/code_test.py b/diabetes_regression/training/test_train.py similarity index 67% rename from tests/unit/code_test.py rename to diabetes_regression/training/test_train.py index 1b133766..155d367a 100644 --- a/tests/unit/code_test.py +++ b/diabetes_regression/training/test_train.py @@ -15,8 +15,13 @@ def test_train_model(): run = Mock(Run) reg = train_model(run, data, alpha=1.2) - run.log.assert_called_with("mse", 0.029843893480257067, - description='Mean squared error metric') + _, call2 = run.log.call_args_list + nameValue, descriptionDict = call2 + name, value = nameValue + description = descriptionDict['description'] + assert (name == 'mse') + np.testing.assert_almost_equal(value, 0.029843893480257067) + assert (description == 'Mean squared error metric') preds = reg.predict([[1], [2]]) np.testing.assert_equal(preds, [9.93939393939394, 9.03030303030303]) diff --git a/docs/development_setup.md b/docs/development_setup.md index 8565ff04..68e6b6bf 100644 --- a/docs/development_setup.md +++ b/docs/development_setup.md @@ -38,7 +38,3 @@ BUILD_BUILDID is a variable used to uniquely identify the ML pipeline between th set to the current build number. In a local environment, we can use a command such as `uuidgen` so set a different random identifier on each run, ensuring there are no collisions. - -### Local testing - -Before committing, run `tox` to execute linter and unit test checks. diff --git a/lint-and-test.sh b/lint-and-test.sh deleted file mode 100755 index 77c646ba..00000000 --- a/lint-and-test.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -eux -flake8 --output-file=lint-testresults.xml --format junit-xml -python -m pytest tests/unit --cov=diabetes_regression --cov-report=html --cov-report=xml --junitxml=unit-testresults.xml diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index e24d8ae1..00000000 --- a/tox.ini +++ /dev/null @@ -1,7 +0,0 @@ -[flake8] -# ignore obsolete warning -ignore = W503 -exclude = .git,__pycache__,.venv,.tox,**/site-packages/**/*.py,**/lib/**.py,**/bin/**.py - -[pytest] -junit_family = legacy