File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed
Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 1+ from unittest .mock import patch
2+ from io import StringIO
3+
14from benedict .dicts .io import IODict
25
36from .test_io_dict import io_dict_test_case
@@ -29,7 +32,6 @@ def test_from_cli_with_valid_data(self):
2932
3033 def test_from_cli_with_invalid_arguments (self ):
3134 s = """--help -h"""
32-
3335 # static method
3436 with self .assertRaises (ValueError ):
3537 IODict .from_cli (s )
@@ -38,13 +40,20 @@ def test_from_cli_with_invalid_arguments(self):
3840 IODict (s , format = "cli" )
3941
4042 def test_from_cli_with_invalid_data (self ):
41- s = "Lorem ipsum est in ea occaecat nisi officia."
42- # static method
43- with self .assertRaises (ValueError ):
44- IODict .from_cli (s )
45- # constructor
46- with self .assertRaises (ValueError ):
47- IODict (s , format = "cli" )
43+ with patch (
44+ "sys.stdout" ,
45+ new_callable = StringIO ,
46+ ), patch (
47+ "sys.stderr" ,
48+ new_callable = StringIO ,
49+ ):
50+ s = "Lorem ipsum est in ea occaecat nisi officia."
51+ # static method
52+ with self .assertRaises (ValueError ):
53+ IODict .from_cli (s )
54+ # constructor
55+ with self .assertRaises (ValueError ):
56+ IODict (s , format = "cli" )
4857
4958 def test_to_cli (self ):
5059 d = IODict (
Original file line number Diff line number Diff line change @@ -19,16 +19,16 @@ def test_yaml_serializer_produces_inconsistent_results(self):
1919 b ["hello.world" ] = "hello world"
2020
2121 # output as custom object using yaml manually
22- print (yaml .dump ({"world" : dict (b )}))
22+ # print(yaml.dump({"world": dict(b)}))
2323
2424 # output as custom object using yaml manually
25- print (yaml .dump ({"world" : b }))
25+ # print(yaml.dump({"world": b}))
2626
2727 # output as normal dict using yaml manually
28- print (yaml .dump ({"world" : b .dict ()}))
28+ # print(yaml.dump({"world": b.dict()}))
2929
3030 # output as normal dict using benedict yaml serializer
31- print (benedict ({"world" : b }).to_yaml ())
31+ # print(benedict({"world": b}).to_yaml())
3232
3333 self .assertEqual (
3434 yaml .dump ({"world" : b .dict ()}),
You can’t perform that action at this time.
0 commit comments