diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 501a9e1c..5bc8f1ec 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -11,19 +11,23 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.7 + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Python uses: actions/setup-python@v2 with: python-version: 3.7 + - name: Setup github username run: | git config --global user.email "fake@example.com" git config --global user.name "fake name" + - name: Setup docker run: | sudo apt install apt-transport-https ca-certificates curl software-properties-common @@ -35,16 +39,15 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install bs4 - pip install pytest - pip install bigflow pip install -r requirements.txt - pip install -r test/requirements.txt - sudo apt install docker - - name: Tests + - name: Run unit tests run: | - python -m unittest discover -s bigflow -t . -p '*.py' - python -m unittest discover -s test -p '*.py' + pytest --html=build/test-report.html --self-contained-html + - name: Upload test report + if: always() + uses: actions/upload-artifact@v2 + with: + name: test-report + path: build/test-report.html diff --git a/pyproject.toml b/pyproject.toml index 194fa38b..994bb1b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.pytest.ini_options] minversion = "6.0" -#addopts = "-ra -q" testpaths = [ "test", + "bigflow", ] diff --git a/requirements.txt b/requirements.txt index 404bc95b..04e00434 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,10 @@ twine freezegun pexpect -responses \ No newline at end of file +responses +bs4 + +pytest +pytest-html +pytest-cov +pytest-github-actions-annotate-failures \ No newline at end of file diff --git a/test/cli/__init__.py b/test/cli/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/cli/test_cli.py b/test/cli/test_cli.py index 6f618a9e..44f193d2 100644 --- a/test/cli/test_cli.py +++ b/test/cli/test_cli.py @@ -1,5 +1,3 @@ -from logging import shutdown -from mock.mock import _set_return_value from bigflow.build.operate import build_project from unittest import TestCase import itertools @@ -7,6 +5,7 @@ import shutil import freezegun +from bigflow.testing.isolate import ForkIsolateMixin from bigflow.cli import * from test import mixins @@ -16,12 +15,14 @@ class CliTestCase( mixins.PrototypedDirMixin, + ForkIsolateMixin, TestCase, ): proto_dir = "bf-projects/example_project" def setUp(self) -> None: super().setUp() + sys.path.append(str(Path(__file__).parent)) self.project_setuppy = self.cwd / "setup.py" @@ -30,12 +31,6 @@ def setUp(self) -> None: bigflow.build.spec.get_project_spec.cache_clear() - def tearDown(self): - try: - import_module("test_module.Unused1").started_jobs.clear() - except ImportError: - pass - def test_should_walk_through_all_files_inside_package_tree(self): # when res = walk_module_files(TEST_MODULE_PATH)