Skip to content

Commit

Permalink
version 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Milk committed Jan 21, 2021
1 parent 90e2c4b commit 510f48a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 53 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on: create

jobs:
Build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python env
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and check
run: |
python setup.py sdist bdist_wheel
twine check dist/*
- name: List dist
run: find dist/*

- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
- name: Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.9]
python-version: [3.8]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

![Test status](https://img.shields.io/github/workflow/status/Mr-Milk/python-hmr/Test?label=Test&logo=github&style=flat-square)
![codecov](https://img.shields.io/codecov/c/github/Mr-Milk/python-hmr?style=flat-square)
![pypi](https://img.shields.io/pypi/v/python-hmr?logoColor=white&style=flat-square)
![license-mit](https://img.shields.io/github/license/Mr-Milk/python-hmr?color=blue&style=flat-square)

Automatic reload your project when files are modified.
Expand Down
32 changes: 0 additions & 32 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,35 +117,3 @@ def reset(self):
@pytest.fixture(scope='module')
def package(create_package):
return Package()


def reload_func(obj, call_obj, package, modify_func, assert_before, assert_after, **kwargs):
obj = Reloader(obj, **kwargs)

package.reset()
obj.reload()
check.equal(getattr(obj, call_obj).__call__(), assert_before)

getattr(package, modify_func).__call__()
cprint("The source code is ", inspect.getsource(getattr(obj, call_obj)))
cprint("The running result is ", getattr(obj, call_obj).__call__())
obj.reload()
check.equal(getattr(obj, call_obj).__call__(), assert_after)

obj.stop()


def reload_class(obj, call_obj, attr, package, modify_func, assert_before, assert_after, **kwargs):
obj = Reloader(obj, **kwargs)

package.reset()
obj.reload()
check.equal(getattr(getattr(obj, call_obj).__call__(), attr), assert_before)

getattr(package, modify_func).__call__()

obj.reload()
cprint(inspect.getsource(getattr(obj, call_obj)))
check.equal(getattr(getattr(obj, call_obj).__call__(), attr), assert_after)

obj.stop()
23 changes: 3 additions & 20 deletions tests/test_submoduel_reload.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from time import sleep

import pytest_check as check
from conftest import reload_func, reload_class


# import X.Y
from hmr import Reloader
Expand All @@ -14,26 +12,11 @@ def test_submodule(package, wait):
sub = Reloader(sub)

package.reset()
check.equal(sub.SubClass().v, 1)
check.equal(sub.sub_func(), "Hi from sub_func")

package.modify_sub_module_class()
package.modify_sub_module_func()
sleep(wait)
check.equal(sub.SubClass().v, 2)
check.equal(sub.sub_func(), "Hello from sub_func")
package.reset()

sub.stop()


# from X import Y
def test_individual_submodule(package, wait):
from my_pkg import sub_module
sub_module = Reloader(sub_module)

package.reset()
check.equal(sub_module.sub_func(), "Hi from sub_func")

package.modify_sub_module_func()
sleep(wait)
check.equal(sub_module.sub_func(), "Hello from sub_func")
package.reset()
sub_module.stop()

0 comments on commit 510f48a

Please sign in to comment.