Added the propertiesfile test to the test suite.
[recordtv.git] / src / rtv_propertiesfile.py
blob04acae1ecf60c91fc723777cdf844204df8c1870
1 #!/usr/bin/python
3 import os
5 from rtv_abstractpropertiesfile import AbstractPropertiesFile
7 class PropertiesFile( AbstractPropertiesFile ):
9 def set_value( self, key, value ):
10 self.__dict__[key] = value
12 def get_value( self, key ):
13 ret = None
14 if key in self.__dict__:
15 ret = self.__dict__[key]
16 return ret
18 def get_keys( self ):
19 return self.__dict__.keys()
21 def test():
22 # Testing code:
24 pf = PropertiesFile()
25 pf.mystr = "Hello2"
26 pf.mystrpipe = "|Hello"
27 pf.mytuple = ( "x", "y", "z" )
28 pf.mylist = [ "xa", "yb", "zc" ]
29 pf.myint = 45
30 pf.myfloat = 5.8
32 filename = "tmp.rtvtestpropertiesfile"
34 pf.save( filename )
36 pf2 = PropertiesFile()
37 pf2.load( filename )
39 os.unlink( filename )
41 #print pf2.__dict__
43 # TODO: assert( pf.__dict__ == pf2.__dict__ )
45 # TODO: test reading a file with spaces around the =, etc.