Skip to content

Commit

Permalink
Run Workflow With Pytest
Browse files Browse the repository at this point in the history
We had issue on windows: python/cpython#90579 (comment)
  • Loading branch information
AliRn76 committed Dec 23, 2023
1 parent 68cb564 commit 4b33469
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 22 deletions.
20 changes: 3 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
pip install -r requirements.txt
- name: Run Tests
run: python -m unittest tests/test_*.py
run: pytest tests

tests-windows:
name: Test Windows Python${{ matrix.python-version }}
Expand All @@ -55,21 +55,7 @@ jobs:
pip install -r requirements.txt
- name: Run Tests
# https://github.com/python/cpython/issues/90579#issuecomment-1860222956
run: |
python -m unittest .\tests\test_background_tasks.py
python -m unittest .\tests\test_caching.py
python -m unittest .\tests\test_cli.py
python -m unittest .\tests\test_mongodb.py
python -m unittest .\tests\multipart.py
python -m unittest .\tests\panel_apis.py
python -m unittest .\tests\test_pantherdb.py
python -m unittest .\tests\test_request.py
python -m unittest .\tests\test_routing.py
python -m unittest .\tests\test_run.py
python -m unittest .\tests\test_simple_responses.py
python -m unittest .\tests\test_status.py
python -m unittest .\tests\test_utils.py
run: pytest tests

tests-macos:
name: Test MacOS Python${{ matrix.python-version }}
Expand All @@ -94,7 +80,7 @@ jobs:
pip install -r requirements.txt
- name: Run Tests
run: python -m unittest tests/test_*.py
run: pytest tests

coverage:
name: Coverage
Expand Down
2 changes: 1 addition & 1 deletion panther/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from panther.main import Panther # noqa: F401

__version__ = '3.2.4'
__version__ = '3.2.5'


def version():
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.
faker
coverage
pytest
Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def check_two_dicts(a: dict, b: dict) -> bool:
return all((k in a and a[k] == v for k, v in b.items()))
9 changes: 5 additions & 4 deletions tests/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from panther import Panther
from panther.app import API
from panther.test import APIClient
from tests._utils import check_two_dicts


@API()
Expand Down Expand Up @@ -42,7 +43,7 @@ def test_without_cache(self):
res2 = self.client.get('without-cache')
assert res2.status_code == 200

assert res1.data != res2.data
assert check_two_dicts(res1.data, res2.data) is False

def test_with_cache(self):
res1 = self.client.get('with-cache')
Expand All @@ -51,7 +52,7 @@ def test_with_cache(self):
res2 = self.client.get('with-cache')
assert res2.status_code == 200

assert res1.data == res2.data
assert check_two_dicts(res1.data, res2.data) is True

def test_with_cache_5second_exp_time(self):
# First Request
Expand All @@ -68,7 +69,7 @@ def test_with_cache_5second_exp_time(self):
assert res2.status_code == 200

# Response should be cached
assert res1.data == res2.data
assert check_two_dicts(res1.data, res2.data) is True

time.sleep(5)

Expand All @@ -77,5 +78,5 @@ def test_with_cache_5second_exp_time(self):
assert res3.status_code == 200

# After 5 seconds we should have a new response
assert res1.data != res3.data
assert check_two_dicts(res1.data, res3.data) is False

0 comments on commit 4b33469

Please sign in to comment.