From bf04f2de8b162519d96d0d1bcc6a542ffce02e60 Mon Sep 17 00:00:00 2001 From: Vinit Kumar Date: Sat, 12 Aug 2023 01:08:14 +0530 Subject: [PATCH 1/3] chore: test python312rc1 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index e9415033..efd27986 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, pypy-3.8, pypy-3.9, pypy-3.10, '3.10', '3.11' , '3.12.0-beta.4'] + python-version: [3.8, 3.9, pypy-3.8, pypy-3.9, pypy-3.10, '3.10', '3.11' , '3.12.0-rc.1'] os: [ ubuntu-latest, windows-latest, From ba79b344cb3aede2c6050bdb18e18d5b76f042ff Mon Sep 17 00:00:00 2001 From: Vinit Kumar Date: Sat, 12 Aug 2023 01:34:23 +0530 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20all=20tests=20go=20brr...=20?= =?UTF-8?q?=F0=9F=8F=8E=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.rst | 2 +- json2xml/dicttoxml.py | 2 +- json2xml/utils.py | 4 ++++ tests/test_json2xml.py | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 532eb29b..60018005 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,7 @@ The library can be used in these ways: from json2xml.utils import readfromurl, readfromstring, readfromjson # get the xml from an URL that return json - data = readfromurl("https://coderwall.com/vinitcool76.json") + data = readfromurl("https://api.publicapis.org/entries") print(json2xml.Json2xml(data).to_xml()) # get the xml from a json string like this: diff --git a/json2xml/dicttoxml.py b/json2xml/dicttoxml.py index 3302753a..ace0e693 100644 --- a/json2xml/dicttoxml.py +++ b/json2xml/dicttoxml.py @@ -247,7 +247,7 @@ def dict2xml_str( val_attr: dict[str, str] = item.pop("@attrs", attr) # update attr with custom @attr if exists rawitem = item["@val"] if "@val" in item else item if is_primitive_type(rawitem): - if type(rawitem) == str: + if isinstance(rawitem , str): subtree = escape_xml(rawitem) else: subtree = rawitem diff --git a/json2xml/utils.py b/json2xml/utils.py index 849cc212..f9a1e94f 100644 --- a/json2xml/utils.py +++ b/json2xml/utils.py @@ -48,6 +48,10 @@ def readfromurl(url: str, params: dict[str, str] | None = None) -> dict[str, str if response.status == 200: data = json.loads(response.data.decode('utf-8')) return data + print("bug") + print(response.status) + print("bug") + print("bug") raise URLReadError("URL is not returning correct response") diff --git a/tests/test_json2xml.py b/tests/test_json2xml.py index 4c3e552e..c1e965c9 100644 --- a/tests/test_json2xml.py +++ b/tests/test_json2xml.py @@ -51,12 +51,12 @@ def test_read_from_invalid_json2(self): assert pytest_wrapped_e.type == JSONReadError def test_read_from_url(self): - data = readfromurl("https://coderwall.com/vinitcool76.json") + data = readfromurl("https://api.publicapis.org/entries") assert type(data) is dict def test_read_from_wrong_url(self): with pytest.raises(URLReadError) as pytest_wrapped_e: - readfromurl("https://coderwall.com/vinitcool76.jsoni") + readfromurl("https://api.publicapis.org/entriesi") assert pytest_wrapped_e.type == URLReadError def test_read_from_jsonstring(self): From 2eb82c9efc5257d1a721b2ff91d10ed3eaa05e3e Mon Sep 17 00:00:00 2001 From: Vinit Kumar Date: Sat, 12 Aug 2023 01:43:14 +0530 Subject: [PATCH 3/3] fix: remove bug log --- json2xml/utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/json2xml/utils.py b/json2xml/utils.py index f9a1e94f..849cc212 100644 --- a/json2xml/utils.py +++ b/json2xml/utils.py @@ -48,10 +48,6 @@ def readfromurl(url: str, params: dict[str, str] | None = None) -> dict[str, str if response.status == 200: data = json.loads(response.data.decode('utf-8')) return data - print("bug") - print(response.status) - print("bug") - print("bug") raise URLReadError("URL is not returning correct response")