Being a bit lazy, I got fed up of copying that test file. It occurred to me today that I should write the test file as part of the test and remove it afterwards.
Why didn't I think of this before?
if __name__ == '__main__':
open('test.properties','w').write("""Param : This is a parameter value
Multi Param : multi parameter 1
+Multi Param : multi parameter 2
+Multi Param : multi parameter 3""")
test_properties = Properties('test.properties')
assert test_properties.property('Param')=='This is a parameter value'
assert test_properties.propertyAsList('Multi Param')==['multi parameter 1','multi parameter 2','multi parameter 3']
os.remove('test.properties')
I guess the tests should be put into some kind of unit test framework, but I can't quite yet be arsed to figure that stuff out. If this horrifies you, please do point me in the right direction.
No comments:
Post a Comment