diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..277f51e --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,15 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + + steps: + - name: Run pytest + uses: cclauss/GitHub-Action-for-pytest@0.5.0 \ No newline at end of file diff --git a/pykson/__init__.py b/pykson/__init__.py index 6df16e9..70b5bfe 100644 --- a/pykson/__init__.py +++ b/pykson/__init__.py @@ -623,9 +623,7 @@ def __get_fields(cls) -> List[Field]: fields_list.append(field) for base in cls.__bases__: base_type_dicts = base.__dict__ # type(self).__dict__ - for n, field in base_type_dicts.items(): - if isinstance(field, Field): - fields_list.append(field) + fields_list += JsonObjectMeta.__get_fields(base) return fields_list @staticmethod diff --git a/test_pykson.py b/test_pykson.py new file mode 100644 index 0000000..2ec6ce5 --- /dev/null +++ b/test_pykson.py @@ -0,0 +1,20 @@ +import pykson + +class Class1(pykson.JsonObject): + variable_1 = pykson.IntegerField(default_value=1) + +class Class2(Class1): + variable_2 = pykson.IntegerField(default_value=2) + +class Class3(Class2): + variable_3 = pykson.IntegerField(default_value=3) + +class Class4(Class3): + variable_4 = pykson.IntegerField(default_value=4) + +def test_multiple_inheritance(): + class4 = Class4() + assert class4.variable_1 == 1 + assert class4.variable_2 == 2 + assert class4.variable_3 == 3 + assert class4.variable_4 == 4 \ No newline at end of file