flag test
This commit is contained in:
parent
8f619b18c2
commit
6db8b61e4c
|
@ -173,7 +173,7 @@ PyParsley_parse_doc(parsedParsleyPtr ptr, char *type) {
|
|||
return output;
|
||||
}
|
||||
|
||||
#define SET_FLAG(C, B) if(!B) flags -= C
|
||||
#define SET_FLAG(C, B) if(B) flags |= C
|
||||
|
||||
|
||||
static PyObject *
|
||||
|
@ -206,6 +206,8 @@ PyParsley_parse(PyParsley *self, PyObject *args, PyObject *keywords)
|
|||
SET_FLAG(PARSLEY_OPTIONS_COLLATE, collate);
|
||||
SET_FLAG(PARSLEY_OPTIONS_ALLOW_NET, allow_net);
|
||||
SET_FLAG(PARSLEY_OPTIONS_ALLOW_LOCAL, allow_local);
|
||||
|
||||
// printf("%d %d %d %d %d \n", prune, collate, allow_net, allow_local, flags);
|
||||
|
||||
if(self->parsley == NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "parsley data is NULL");
|
||||
|
|
|
@ -9,22 +9,31 @@ class TestPyParsley(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.parsley = PyParsley({'title': 'title'})
|
||||
self.alt_parsley = PyParsley('{"title": "title"}')
|
||||
self.a_parsley = PyParsley({'links': ['regexp:match(a @href, ".*sign.*")']})
|
||||
self.__file__ = currentframe().f_code.co_filename
|
||||
self.__dir__ = dirname(self.__file__)
|
||||
self.file = self.__dir__ + '/yelp.html'
|
||||
self.json = '{ "title": "\\t\\tNick\'s Crispy Tacos - Russian Hill - San Francisco, CA\\n" }'
|
||||
self.native = { "title": "\t\tNick's Crispy Tacos - Russian Hill - San Francisco, CA\n" }
|
||||
self.links = '{ "links": [ "\\/signup?return_url=%2Fuser_details", "\\/signup?return_url=%2Fwriteareview", "\\/signup?return_url=%2Finvite_friends", "\\/signup?return_url=%2Fmail", "\\/signup?return_url=%2Fprofile", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup", "\\/signup" ] }'
|
||||
|
||||
def test_file_xml(self):
|
||||
parsed = self.parsley.parse(file = self.file, output = "json")
|
||||
self.assertEquals(self.json, parsed)
|
||||
|
||||
|
||||
def test_pruning(self):
|
||||
parsed = self.a_parsley.parse(file = self.file, output = "json")
|
||||
self.assertEquals(self.links, parsed)
|
||||
|
||||
def test_json_file_xml(self):
|
||||
parsed = self.alt_parsley.parse(file = self.file, output = "json")
|
||||
self.assertEquals(self.json, parsed)
|
||||
|
||||
def test_native(self):
|
||||
parsed = self.alt_parsley.parse(file = self.file, output = "python")
|
||||
self.assertEquals({ "title": "\t\tNick's Crispy Tacos - Russian Hill - San Francisco, CA\n" }, parsed)
|
||||
self.assertEquals(self.native, parsed)
|
||||
parsed = self.alt_parsley.parse(file = self.file)
|
||||
self.assertEquals(self.native, parsed)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in New Issue