本文整理汇总了Python中utils.path_to_text_fixture函数的典型用法代码示例。如果您正苦于以下问题:Python path_to_text_fixture函数的具体用法?Python path_to_text_fixture怎么用?Python path_to_text_fixture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_to_text_fixture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_xls_to_csv
def test_xls_to_csv(self):
specify_other_xls = utils.path_to_text_fixture("specify_other.xls")
converted_xls = convert_file_to_csv_string(specify_other_xls)
specify_other_csv = utils.path_to_text_fixture("specify_other.csv")
converted_csv = convert_file_to_csv_string(specify_other_csv)
# print "csv:"
# print converted_csv
# print "xls:"
# print converted_xls
self.assertEqual(converted_csv, converted_xls)
示例2: test_equivalency
def test_equivalency(self):
equivalent_fixtures = ['group', 'loop', #'gps',
'specify_other', 'include', 'text_and_integer', \
'include_json', 'yes_or_no_question']
for fixture in equivalent_fixtures:
xls_path = utils.path_to_text_fixture("%s.xls" % fixture)
csv_path = utils.path_to_text_fixture("%s.csv" % fixture)
xls_inp = xls_to_dict(xls_path)
csv_inp = csv_to_dict(csv_path)
self.assertEqual(csv_inp, xls_inp)
示例3: test_table
def test_table(self):
x = SurveyReader(utils.path_to_text_fixture("simple_loop.xls"))
expected_dict = {
u'type': u'survey',
u'name': u'simple_loop',
u'id_string': u'simple_loop',
u'default_language': u'default',
u'title': u'simple_loop',
u'children': [
{
u'children': [
{
u'type': u'integer',
u'name': u'count',
u'label': {u'English': u'How many are there in this group?'}
}
],
u'type': u'loop',
u'name': u'my_table',
u'columns': [
{
u'name': u'col1',
u'label': {u'English': u'Column 1'}
},
{
u'name': u'col2',
u'label': {u'English': u'Column 2'}
}
],
u'label': {u'English': u'My Table'}
}]}
self.maxDiff = None
self.assertEqual(x.to_json_dict(), expected_dict)
示例4: test_hidden
def test_hidden(self):
x = SurveyReader(utils.path_to_text_fixture("hidden.xls"))
x_results = x.to_json_dict()
expected_dict = [
{
u'type': u'hidden',
u'name': u'hidden_test'
},
{
'children': [
{
'bind': {
'calculate': "concat('uuid:', uuid())",
'readonly': 'true()'
},
'name': 'instanceID',
'type': 'calculate'
}
],
'control': {
'bodyless': True
},
'name': 'meta',
'type': 'group'
}
]
self.assertEqual(x_results[u"children"], expected_dict)
示例5: test_table
def test_table(self):
x = SurveyReader(utils.path_to_text_fixture("simple_loop.xls"))
expected_dict = {
u"type": u"survey",
u"name": u"simple_loop",
u"id_string": u"simple_loop",
u"default_language": u"default",
u"title": u"simple_loop",
u"children": [
{
u"children": [
{
u"type": u"integer",
u"name": u"count",
u"label": {u"English": u"How many are there in this group?"},
}
],
u"type": u"loop",
u"name": u"my_table",
u"columns": [
{u"name": u"col1", u"label": {u"English": u"Column 1"}},
{u"name": u"col2", u"label": {u"English": u"Column 2"}},
],
u"label": {u"English": u"My Table"},
}
],
}
self.maxDiff = None
self.assertEqual(x.to_json_dict(), expected_dict)
示例6: test_json
def test_json(self):
x = SurveyReader(utils.path_to_text_fixture("group.xls"))
x_results = x.to_dict()
expected_dict = {
u'name': 'group',
u'type': u'survey',
u'children': [
{
u'name': u'family_name',
u'type': u'text',
u'label': {u'English': u"What's your family name?"}
},
{
u'name': u'father',
u'type': u'group',
u'label': {u'English': u'Father'},
u'children': [
{
u'name': u'phone_number',
u'type': u'phone number',
u'label': {u'English': u"What's your father's phone number?"}
},
{
u'name': u'age',
u'type': u'integer',
u'label': {u'English': u'How old is your father?'}
}
],
}
],
}
self.assertEqual(x_results, expected_dict)
示例7: setUp
def setUp(self):
self.excel_files = [
"gps.xls",
#"include.xls",
"specify_other.xls",
"loop.xls",
"text_and_integer.xls",
# todo: this is looking for json that is created (and
# deleted) by another test, is should just add that json
# to the directory.
# "include_json.xls",
"simple_loop.xls",
"yes_or_no_question.xls",
"xlsform_spec_test.xlsx",
"group.xls",
]
self.surveys = {}
self.this_directory = os.path.dirname(__file__)
for filename in self.excel_files:
path = utils.path_to_text_fixture(filename)
try:
self.surveys[filename] = create_survey_from_path(path)
except Exception as e:
print("Error on : " + filename)
raise e
示例8: test_gps
def test_gps(self):
x = SurveyReader(utils.path_to_text_fixture("gps.xls"))
expected_dict = [
{
u'type': u'gps', u'name': u'location', u'label': u'GPS'},
{
'children': [
{
'bind': {
'calculate': "concat('uuid:', uuid())",
'readonly': 'true()'
},
'name': 'instanceID',
'type': 'calculate'
}
],
'control': {
'bodyless': True
},
'name': 'meta',
'type': 'group'
}]
self.assertEqual(x.to_json_dict()[u"children"], expected_dict)
示例9: test_for_loop
def test_for_loop(self):
path = utils.path_to_text_fixture('for_loop.xls')
survey = create_survey_from_xls(path)
self.maxDiff = None
try:
actual_xml = survey.to_xml()
except ValidationError:
self.fail("survey.to_xml() raised ValidationError.")
示例10: test_a_unicode_csv_works
def test_a_unicode_csv_works(self):
"""
Simply tests that xls2json_backends.csv_to_dict does not have a problem
with a csv with unicode characters
"""
utf_csv_path = utils.path_to_text_fixture("utf_csv.csv")
dict_value = csv_to_dict(utf_csv_path)
self.assertTrue("\ud83c" in json.dumps(dict_value))
示例11: test_create_from_path
def test_create_from_path(self):
path = utils.path_to_text_fixture("area.xlsx")
survey = create_survey_from_path(path)
path = os.path.join(
os.path.dirname(__file__), 'test_expected_output', 'area.xml')
with codecs.open(path, encoding='utf-8') as f:
self.assertMultiLineEqual(survey.to_xml(), f.read())
示例12: test_new_widgets
def test_new_widgets(self):
survey = utils.build_survey('widgets.xls')
path = utils.path_to_text_fixture('widgets.xml')
survey.to_xml
with open(path) as f:
expected = etree.fromstring(survey.to_xml())
result = etree.fromstring(f.read())
self.assertTrue(xml_compare(expected, result))
示例13: runTest
def runTest(self):
path_to_excel_file = utils.path_to_text_fixture("warnings.xls")
warnings = []
xls2json.parse_file_to_json(path_to_excel_file, warnings=warnings)
#print '\n'.join(warnings)
self.assertEquals(len(warnings), 17, "Found " + str(len(warnings)) + " warnings")
示例14: test_equivalency
def test_equivalency(self):
equivalent_fixtures = [
"group",
"loop", #'gps',
"specify_other",
"include",
"text_and_integer",
"include_json",
"yes_or_no_question",
]
for fixture in equivalent_fixtures:
xls_path = utils.path_to_text_fixture("%s.xls" % fixture)
csv_path = utils.path_to_text_fixture("%s.csv" % fixture)
xls_inp = xls_to_dict(xls_path)
csv_inp = csv_to_dict(csv_path)
self.maxDiff = None
self.assertEqual(csv_inp, xls_inp)
示例15: setUp
def setUp(self):
self.this_directory = os.path.dirname(__file__)
survey_out = Survey(name=u"age", sms_keyword=u"age", type=u"survey")
question = InputQuestion(name=u"age")
question.type = u"integer"
question.label = u"How old are you?"
survey_out.add_child(question)
self.survey_out_dict = survey_out.to_json_dict()
print_pyobj_to_json(self.survey_out_dict, utils.path_to_text_fixture("how_old_are_you.json"))