summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Wren <jonathan@nowandwren.com>2023-05-06 16:28:33 -0700
committerJonathan Wren <jonathan@nowandwren.com>2023-05-06 16:28:33 -0700
commitd40b013bcd283aad622353bd2bf3935d3f936f0b (patch)
treea8b9eebc627d0c243b5e47a04c055f341d95395f
parent7b5d3fdaf9527b24eae97faa66ceb9f8ed339512 (diff)
update testsruamel-tox-example
-rw-r--r--jrnl/main.py10
-rw-r--r--tests/test_run.py4
2 files changed, 9 insertions, 5 deletions
diff --git a/jrnl/main.py b/jrnl/main.py
index d39dae77..3c09c9cf 100644
--- a/jrnl/main.py
+++ b/jrnl/main.py
@@ -1,13 +1,17 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
-from ruamel import yaml
+from ruamel.yaml import YAML
import sys
+from io import StringIO
-def run(num = None):
+
+def run(num=None):
if num is None:
num = sys.argv[1]
my_str = "a" * int(num)
my_dict = dict(a=my_str, b=dict(c=1, d=2))
- return yaml.dump(my_dict)
+ output = StringIO()
+ YAML().dump(my_dict, output)
+ return output.getvalue()
diff --git a/tests/test_run.py b/tests/test_run.py
index d7718900..e4a613a4 100644
--- a/tests/test_run.py
+++ b/tests/test_run.py
@@ -6,10 +6,10 @@ from jrnl.main import run
def test_passes():
num = 80
- assert run(num) == "a: " + ("a" * num) + "\nb: {c: 1, d: 2}\n"
+ assert run(num) == "a: " + ("a" * num) + "\nb:\n c: 1\n d: 2\n"
def test_fails():
num = 81
- assert run(num) == "a: " + ("a" * num) + "\nb: {c: 1, d: 2}\n"
+ assert run(num) == "a: " + ("a" * num) + "\nb:\n c: 1\n d: 2\n"