def test_validate(test_path_object=False):
 output = io.StringIO()
 fpath = get_pkg_data_filename(u'data/regression.xml')
 if test_path_object:
  fpath = pathlib.Path(fpath)
 with catch_warnings():
  result = validate(fpath, output, xmllint=False)
 assert (result is False)
 output.seek(0)
 output = output.readlines()
 with io.open(get_pkg_data_filename(u'data/validation.txt'), u'rt', encoding=u'utf-8') as fd:
  truth = fd.readlines()
 truth = truth[1:]
 output = output[1:(-1)]
 for line in difflib.unified_diff(truth, output):
  if six.PY2:
   sys.stdout.write(line.encode(u'unicode_escape').replace(u'\\n', u'\n'))
  else:
   sys.stdout.write(line.replace(u'\\n', u'\n'))
 assert (truth == output)

def test_validate ( test_path_object = False ) : output = io . StringIO ( ) fpath = get_pkg_data_filename ( u'data/regression.xml' ) if test_path_object : fpath = pathlib . Path ( fpath ) with catch_warnings ( ) : result = validate ( fpath , output , xmllint = False ) assert ( result is False ) output . seek ( 0 ) output = output . readlines ( ) with io . open ( get_pkg_data_filename ( u'data/validation.txt' ) , u'rt' , encoding = u'utf-8' ) as fd : truth = fd . readlines ( ) truth = truth [ 1 : ] output = output [ 1 : ( - 1 ) ] for line in difflib . unified_diff ( truth , output ) : if six . PY2 : sys . stdout . write ( line . encode ( u'unicode_escape' ) . replace ( u'\\n' , u'\n' ) ) else : sys . stdout . write ( line . replace ( u'\\n' , u'\n' ) ) assert ( truth == output )
test_path_object is needed for test below test_validate_path_object so that file could be passed as pathlib .