Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop obsolete dependencies #513

Merged
merged 5 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ dependencies = [
'websockets',
'addict>=2.4.0',
'jinja2>=3.1.2',
'demjson3>=3.0.5',
'hjson>=3.1.0',
'PyYAML>=6.0',
'httpx>=0.23.0',
'httpx>=0.23.0',
'aiofiles',
'twine',
'wheel'
Expand Down
80 changes: 0 additions & 80 deletions tests/test_benchmark_decode.py

This file was deleted.

79 changes: 0 additions & 79 deletions tests/test_demjson.py

This file was deleted.

74 changes: 46 additions & 28 deletions tests/test_jsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,55 @@

@author: hr
"""
import os
import unittest
from timeit import timeit

import hjson

from tests.basetest import Basetest
from addict import Dict

SLOW_TESTS = bool(os.environ.get('JP_SLOW_TESTS', False))


class TestJavaScriptObject(Basetest):
"""
Tests JavaScript object conversion via PyYaml
Tests JavaScript object conversion via hjson
"""

# example options string see
# https://www.highcharts.com/docs/getting-started/how-to-set-options
options_string: str = """{
chart: {
renderTo: 'container',
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
}"""

def test_decode(self):
"""
test JavaScript object decoding
"""
# example options string see
# https://www.highcharts.com/docs/getting-started/how-to-set-options
options_string = """{
chart: {
renderTo: 'container',
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
}"""
options = Dict(hjson.loads(options_string.encode("ascii", "ignore")))
options = Dict(hjson.loads(self.options_string.encode("ascii", "ignore")))
debug = self.debug
# debug=True
if debug:
Expand Down Expand Up @@ -104,3 +111,14 @@ def test_decode_dirty_js2(self):
options = hjson.loads(dirty_js)
self.assertTrue("key2" in options)
self.assertTrue("key" in options)

@unittest.skipIf(not SLOW_TESTS, "JP_SLOW_TESTS")
def test_decode_time(self):
"""
test decoding time
"""
no_runs = 1000
elapsed = timeit(lambda: hjson.loads(self.options_string.encode("ascii", "ignore")),
number=no_runs)
print(f'Time elapsed for {no_runs} runs: {elapsed:.2f}s')
self.assertGreater(elapsed, 0.0)