Skip to content

Commit

Permalink
feat: test python3.8 and 3.9 with gh actions (#27)
Browse files Browse the repository at this point in the history
* feat: test python3.8 and 3.9 with gh actions

* feat(test): TestSemaphore test cls

* fix(test): missing test deps
  • Loading branch information
BobTheBuidler authored Mar 7, 2023
1 parent 67934a1 commit e1d0938
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/pytest3.8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: PyTest 3.8

on:
push:
branch: dev
paths:
- '**.py'
- '**/pytest3.8.yaml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, dev ]
paths:
- '**.py'
- '**/pytest3.8.yaml'

jobs:
test:
runs-on: ${{ matrix.os }}
#timeout-minutes: 10
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
path: ~/.cache/pip
- os: macos-latest
path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Setup Python (faster than using Python container)
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Cache dependencies
uses: actions/cache@v3
with:
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-dev.txt') }}
path: |
${{ matrix.path }}
- name: Cache joblib middleware cache
uses: actions/cache@v3
with:
# Include requirements.txt so we recache if web3 version changes
key: forceupdatedeletethislater3-${{ runner.os }}-${{ matrix.network }}-${{ hashFiles('**/middleware.py') }}-${{ hashFiles('**/requirements.txt') }}
path: |
./cache/*/joblib/web3/middleware/filter/middleware
- name: Install dependencies
run: |
pip install pytest
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run test suite
run: pytest

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: PyTest
name: PyTest 3.9

on:
push:
branch: dev
paths:
- '**.py'
- '**/pytest.yaml'
- '**/pytest3.9.yaml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, dev ]
paths:
- '**.py'
- '**/pytest.yaml'
- '**/pytest3.9.yaml'

jobs:
test:
Expand Down Expand Up @@ -56,6 +56,7 @@ jobs:
run: |
pip install pytest
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run test suite
run: pytest
Expand Down
26 changes: 26 additions & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,29 @@ class TestSingleton(ASyncGenericSingleton, TestClass):
class TestSingletonMeta(TestClass, metaclass=ASyncSingletonMeta):
semaphore = 1
pass

class TestSemaphore(ASyncBase):
semaphore=1 # NOTE: this is detected propely by undecorated test_fn but not the properties

def __init__(self, v: int, sync: bool):
self.v = v
self.sync = sync

# spec on class and function both working
#@a_sync.a_sync(semaphore=1)
async def test_fn(self) -> int:
await asyncio.sleep(1)
return self.v


# spec on class, function, property all working
@a_sync.aka.property#('async', semaphore=1)
async def test_property(self) -> int:
await asyncio.sleep(1)
return self.v * 2

# spec on class, function, property all working
@a_sync.alias.cached_property(semaphore=50)
async def test_cached_property(self) -> int:
await asyncio.sleep(1)
return self.v * 3

0 comments on commit e1d0938

Please sign in to comment.