Skip to content

Commit

Permalink
Add a basic test file for yaml.load and yaml.dump
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Sep 23, 2021
1 parent 7bd92df commit 2f87ac4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/lib/test_appliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def run(collections, args=None):
for function in test_functions:
if include_functions and function.__name__ not in include_functions:
continue
if function.unittest:
if function.unittest and function.unittest is not True:
for base, exts in test_filenames:
if include_filenames and base not in include_filenames:
continue
Expand Down
24 changes: 24 additions & 0 deletions tests/lib/test_dump_load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import yaml

def test_dump(verbose=False):
assert yaml.dump(['foo'])
test_dump.unittest = True

def test_load_no_loader(verbose=False):
try:
yaml.load("- foo\n")
except TypeError:
return True
assert(False, "load() require Loader=...")

test_load_no_loader.unittest = True

def test_load_safeloader(verbose=False):
assert yaml.load("- foo\n", Loader=yaml.SafeLoader)
test_load_safeloader.unittest = True

if __name__ == '__main__':
import sys, test_load
sys.modules['test_load'] = sys.modules['__main__']
import test_appliance
test_appliance.run(globals())
1 change: 1 addition & 0 deletions tests/lib/test_yaml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from test_dump_load import *
from test_mark import *
from test_reader import *
from test_canonical import *
Expand Down

0 comments on commit 2f87ac4

Please sign in to comment.