diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml new file mode 100644 index 0000000..8b21d2a --- /dev/null +++ b/.github/workflows/python-lint.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Linter - flake8 + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --exclude test,venv --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --exclude test,venv --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics \ No newline at end of file diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml new file mode 100644 index 0000000..c574a23 --- /dev/null +++ b/.github/workflows/python-test.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Integration tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - run: git clone https://github.com/mandrewcito/signalrcore-containertestservers containers + - run: docker-compose -f containers/docker-compose.yml up -d + - uses: actions/checkout@v2 + - name: Set up Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 coverage + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Test and coverage + run: | + # Test + coverage run -m unittest discover -s test/ -p "*_test.py" \ No newline at end of file diff --git a/setup.py b/setup.py index eda8795..d8174a7 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="signalrcore", - version="0.9.3", + version="0.9.4", author="mandrewcito", author_email="anbaalo@gmail.com", description="A Python SignalR Core client(json and messagepack), with invocation auth and two way streaming. Compatible with azure / serverless functions. Also with automatic reconnect and manually reconnect.", diff --git a/test/reconnection_test.py b/test/reconnection_test.py index caf4213..9d78823 100644 --- a/test/reconnection_test.py +++ b/test/reconnection_test.py @@ -87,19 +87,20 @@ def test_no_reconnect(self): del _lock def reconnect_test(self, connection): - self._lock = threading.Lock() + _lock = threading.RLock() - connection.on_open(lambda: self._lock.release()) + connection.on_open(lambda: _lock.release()) connection.start() - self.assertTrue(self._lock.acquire(timeout=10)) # Release on Open + self.assertTrue(_lock.acquire(timeout=10)) # Release on Open connection.send("DisconnectMe", []) - self.assertTrue(self._lock.acquire(timeout=10)) # released on open + self.assertTrue(_lock.acquire(timeout=10)) # released on open connection.stop() + del _lock def test_raw_reconnection(self): connection = HubConnectionBuilder()\