Skip to content

Commit

Permalink
Merge d50b2ed into 90e1674
Browse files Browse the repository at this point in the history
  • Loading branch information
spyoungtech committed Aug 1, 2021
2 parents 90e1674 + d50b2ed commit f114a22
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 32 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/unittests.yml
@@ -0,0 +1,28 @@
on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install sly coverage regex pytest
- name: Test with coverage/pytest
run: |
coverage run -m pytest tests
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install --upgrade coveralls
coveralls --service=github
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

31 changes: 17 additions & 14 deletions json5/dumper.py
@@ -1,3 +1,4 @@
from .loader import JsonIdentifier
from .utils import singledispatchmethod
from json5.model import *
from collections import UserDict
Expand Down Expand Up @@ -80,24 +81,26 @@ def dict_to_json(self, d):
@to_json(int)
def int_to_json(self, i):
self.env.write(str(i), indent=0)


@to_json(JsonIdentifier)
def identifier_to_json(self, s):
if isinstance(s, JsonIdentifier):
quote_char = None
elif "'" in s:
quote_char = '"'
else:
quote_char = "'"

if quote_char:
self.env.write(quote_char, indent=0)
self.env.write(s, indent=0)
if quote_char:
self.env.write(quote_char, indent=0)

@to_json(str)
def str_to_json(self, s):
self.env.write(json.dumps(s), indent=0)
# if isinstance(s, JsonIdentifier):
# quote_char = None
# elif "'" in s:
# quote_char = '"'
# else:
# quote_char = "'"
#
# if quote_char:
# self.env.write(quote_char, indent=0)
# self.env.write(s, indent=0)
# if quote_char:
# self.env.write(quote_char, indent=0)



@to_json(list)
def list_to_json(self, l):
Expand Down
10 changes: 9 additions & 1 deletion tests/test_json5_official_tests.py
Expand Up @@ -27,7 +27,15 @@ def test_official_files(fp):
load(open(fp, encoding='utf-8'))

@pytest.mark.parametrize('fp', specs)
def test_official_files_rt(fp):
def test_official_files_rt_dumps_no_error(fp):
if not os.path.exists(tests_path):
pytest.mark.skip("Tests repo was not present in expected location. Skipping.")
with open(fp, encoding='utf-8') as f:
json_string = f.read()
dumps(loads(json_string))

@pytest.mark.parametrize('fp', specs)
def test_official_files_rt_model(fp):
if not os.path.exists(tests_path):
pytest.mark.skip("Tests repo was not present in expected location. Skipping.")
with open(fp, encoding='utf-8') as f:
Expand Down

0 comments on commit f114a22

Please sign in to comment.