Skip to content

Commit

Permalink
Fix dependencies for python 3.9 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultmaster authored Jul 14, 2023
1 parent 5ef5e0c commit bc4697c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"

steps:
- uses: actions/checkout@v2
Expand All @@ -25,8 +29,7 @@ jobs:
pip install flake8 pytest pytest-cov wheel
- name: Install package
run: |
python setup.py develop
pip install -e .[full]
pip install .[full]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
28 changes: 7 additions & 21 deletions tests/test_config_type_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@


def test_path():
TypeDef.load(pathlib.Path, '/bin') == pathlib.Path('/bin')
TypeDef.load(os.PathLike, '/bin') == pathlib.Path('/bin')
TypeDef.load(pathlib.PosixPath, '/bin') == pathlib.Path('/bin')
TypeDef.dump(pathlib.Path, pathlib.Path('/bin')) == '/bin'
assert TypeDef.load(pathlib.Path, '/bin') == pathlib.Path('/bin')
assert TypeDef.load(os.PathLike, '/bin') == pathlib.Path('/bin')
assert TypeDef.load(pathlib.PosixPath, '/bin') == pathlib.Path('/bin')
assert TypeDef.dump(pathlib.Path, pathlib.Path('/bin')) == '/bin'


def test_any():
TypeDef.load(typing.Any, 123) == 123
TypeDef.dump(typing.Any, '456') == '456'
assert TypeDef.load(typing.Any, 123) == 123
assert TypeDef.dump(typing.Any, '456') == '456'


def test_unsupported_type():
Expand Down Expand Up @@ -113,7 +113,7 @@ class MyEnum(str, Enum):

assert TypeDef.load(MyEnum, 'state2_val') == MyEnum.state2
assert TypeDef.dump(MyEnum, MyEnum.state1) == 'state1_val'
with pytest.raises(ValidationError, match='is not a valid MyEnum'):
with pytest.raises(ValidationError, match='is not a valid'):
TypeDef.load(MyEnum, 'other')
with pytest.raises(ValidationError, match='Expect a enum'):
TypeDef.dump(MyEnum, 'state1_val')
Expand Down Expand Up @@ -259,17 +259,3 @@ def __init__(self, a: typing.Union[submodule, ClassConfig[submodule]],
{'a': {'a': 1, 'b': 2}, 'b': {'a': 3, 'b': 4, 'c': 5}}).b.c == 5
assert TypeDef.load(ClassConfig[module],
{'a': {'a': 1, 'b': 2}, 'b': {'a': 3, 'b': 4, 'c': 5}}).build().b._c == 5


test_path()
test_optional()
test_any()
test_unsupported_type()
test_primitive()
test_list()
test_tuple()
test_dict()
test_enum()
test_dataclass()
test_union()
test_class_config()

0 comments on commit bc4697c

Please sign in to comment.