From d14fa841da3a3a897f9bd7fa624c797dd4dd101d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Wed, 19 Jan 2022 08:19:39 -0300 Subject: [PATCH 1/3] pykson: JsonObjectMeta: Run __get_fields for each base class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #15 Signed-off-by: Patrick José Pereira --- pykson/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 From 6cb145b37dd754dc83558f7ce5ac23eb7ec57ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Wed, 19 Jan 2022 08:26:31 -0300 Subject: [PATCH 2/3] Add test file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- test_pykson.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test_pykson.py 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 From b94721869eb50bde04f0256031ac95597d9225e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Wed, 19 Jan 2022 08:26:44 -0300 Subject: [PATCH 3/3] ci: Add github action with pytest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- .github/workflows/pytest.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/pytest.yml 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