File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1
1
import unittest
2
2
import odml
3
3
import os
4
+ import sys
4
5
import odml .validation
5
6
import odml .terminology
6
7
from . import test_samplefile as samplefile
7
8
9
+ try :
10
+ from StringIO import StringIO
11
+ except ImportError :
12
+ from io import StringIO
13
+
8
14
validate = odml .validation .Validation
9
15
10
16
@@ -176,6 +182,19 @@ def test_standalone_property(self):
176
182
for err in validate (prop ).errors :
177
183
assert not err .is_error
178
184
185
+ def test_section_init (self ):
186
+ """
187
+ Test validation errors printed to stdout on section init.
188
+ """
189
+ val_errs = StringIO ()
190
+
191
+ old_stdout = sys .stdout
192
+ sys .stdout = val_errs
193
+ odml .Section (name = "sec" , type = None )
194
+ sys .stdout = old_stdout
195
+
196
+ assert "Section type undefined" in val_errs .getvalue ()
197
+
179
198
def test_prop_string_values (self ):
180
199
"""
181
200
Test if property values set as dtype string but could be of different dtype
You can’t perform that action at this time.
0 commit comments