From e9e9c3d57719551bbad7b8176f2830d0cf9a5597 Mon Sep 17 00:00:00 2001 From: David Brown Date: Thu, 3 Nov 2016 18:05:43 -0700 Subject: [PATCH] add test to show how it works a bit more --- testing/resources/top_sorted_json.json | 16 ++++++++++++++++ tests/pretty_format_json_test.py | 5 +++++ 2 files changed, 21 insertions(+) create mode 100644 testing/resources/top_sorted_json.json diff --git a/testing/resources/top_sorted_json.json b/testing/resources/top_sorted_json.json new file mode 100644 index 0000000..62083e7 --- /dev/null +++ b/testing/resources/top_sorted_json.json @@ -0,0 +1,16 @@ +{ + "01-alist": [ + 2, + 34, + 234 + ], + "alist": [ + 2, + 34, + 234 + ], + "00-foo": "bar", + "02-blah": null, + "blah": null, + "foo": "bar" +} diff --git a/tests/pretty_format_json_test.py b/tests/pretty_format_json_test.py index 72c2b86..7bfc31f 100644 --- a/tests/pretty_format_json_test.py +++ b/tests/pretty_format_json_test.py @@ -75,6 +75,11 @@ def test_not_orderfile_get_pretty_format(): assert ret == 1 +def test_top_sorted_get_pretty_format(): + ret = pretty_format_json(['--top-keys=01-alist,alist', get_resource_path('top_sorted_json.json')]) + assert ret == 0 + + def test_badfile_pretty_format_json(): ret = pretty_format_json([get_resource_path('ok_yaml.yaml')]) assert ret == 1