Skip to content

Commit

Permalink
Merge pull request #252 from allegro/aj-use-pytest
Browse files Browse the repository at this point in the history
Use pytest on CI
  • Loading branch information
anjensan authored Jun 10, 2021
2 parents d38bc4a + 112a0cf commit 9fcc5a7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
git config --global user.name "fake name"
- name: Setup docker
run: |
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Expand All @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.pytest.ini_options]
minversion = "6.0"
#addopts = "-ra -q"
testpaths = [
"test",
"bigflow",
]
8 changes: 7 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
twine
freezegun
pexpect
responses
responses
bs4

pytest
pytest-html
pytest-cov
pytest-github-actions-annotate-failures
Empty file added test/cli/__init__.py
Empty file.
11 changes: 3 additions & 8 deletions test/cli/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from logging import shutdown
from mock.mock import _set_return_value
from bigflow.build.operate import build_project
from unittest import TestCase
import itertools
import mock
import shutil
import freezegun

from bigflow.testing.isolate import ForkIsolateMixin
from bigflow.cli import *

from test import mixins
Expand All @@ -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"

Expand All @@ -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)
Expand Down

0 comments on commit 9fcc5a7

Please sign in to comment.