Skip to content

Commit 07e3e6f

Browse files
committed
[test] Update tests after section type change
1 parent ec375ab commit 07e3e6f

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

test/test_doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def test_create_section(self):
312312
self.assertEqual(len(root.sections), 2)
313313
self.assertEqual(subsec.parent, root)
314314
self.assertEqual(root.sections[name], subsec)
315-
self.assertEqual(root.sections[name].type, "undefined")
315+
self.assertEqual(root.sections[name].type, "n.s.")
316316

317317
name = "subsubsec"
318318
subsec = root.sections[0].create_section(name)

test/test_section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ def test_create_section(self):
906906
self.assertEqual(len(root.sections), 2)
907907
self.assertEqual(subsec.parent, root)
908908
self.assertEqual(root.sections[name], subsec)
909-
self.assertEqual(root.sections[name].type, "undefined")
909+
self.assertEqual(root.sections[name].type, "n.s.")
910910

911911
name = "subsubsec"
912912
subsec = root.sections[0].create_section(name)

test/test_validation.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ def test_property_values_cardinality(self):
8484
self.assertFalse(err.is_error)
8585
self.assertIn(test_msg, err.msg)
8686

87-
def test_section_type(self):
88-
doc = samplefile.parse("""s1[undefined]""")
89-
res = validate(doc)
90-
# the section type is undefined (also in the mapping)
91-
self.assertError(res, "Section type undefined")
92-
9387
def test_section_in_terminology(self):
9488
doc = samplefile.parse("""s1[T1]""")
9589
res = validate(doc)
@@ -202,17 +196,12 @@ def test_property_name_readable(self):
202196
def test_standalone_section(self):
203197
"""
204198
Test if standalone section does not return errors if required attributes are correct.
205-
If type is undefined, check error message.
199+
If type is not specified, check error message.
206200
"""
207201

208202
sec_one = odml.Section("sec1")
209-
210203
res = validate(sec_one)
211-
self.assertError(res, "Section type undefined")
212-
213-
doc = samplefile.parse("""s1[undefined]""")
214-
res = validate(doc)
215-
self.assertError(res, "Section type undefined")
204+
self.assertError(res, "Section type not specified")
216205

217206
def test_standalone_property(self):
218207
"""
@@ -229,14 +218,15 @@ def test_section_init(self):
229218
"""
230219
Test validation errors printed to stdout on section init.
231220
"""
232-
val_errs = StringIO()
221+
check_msg = "Missing required attribute 'type'"
233222

223+
val_errs = StringIO()
234224
old_stdout = sys.stdout
235225
sys.stdout = val_errs
236226
odml.Section(name="sec", type=None)
237227
sys.stdout = old_stdout
238228

239-
self.assertIn("Section type undefined", val_errs.getvalue())
229+
self.assertIn(check_msg, val_errs.getvalue())
240230

241231
def test_prop_string_values(self):
242232
"""
@@ -246,7 +236,7 @@ def test_prop_string_values(self):
246236

247237
prop0 = odml.Property(name='words', dtype="string",
248238
values=['-13', '101', '-11', 'hello'])
249-
assert len(validate(prop0).errors) == 0
239+
self.assertEquals(len(validate(prop0).errors), 0)
250240

251241
msg_base = 'Dtype of property "%s" currently is "string", but might fit dtype "%s"!'
252242

0 commit comments

Comments
 (0)