コード例 #1
0
ファイル: tests.py プロジェクト: hacklabcz/pearl
class PropertyTestCase(unittest.TestCase):
    def setUp(self):
        self.path = '/tmp/prop_file'
        f = open(self.path, 'w')
        f.write('# qst e\' una prova\n')
        f.write('var = "value"')
        f.close()
        self.prop = Property(self.path)
        
        self.path_sess = '/tmp/prop_file_session'
        self.path_sess_dir = '/tmp/prop_file_session.d'
        f = open(self.path_sess, 'w')
        f.write('# qst e\' una prova\n')
        f.close()
        os.mkdir(self.path_sess_dir)
        f_s = open(self.path_sess_dir+'/test', 'w')
        f_s.write('var = 45')
        f_s.close()
        self.prop_sess = Property(self.path_sess, True)

        
    def tearDown(self):
        """
        Deletes the file for the next tests.
        """
        if os.path.exists(self.path):
            os.system('rm '+ self.path)
        if os.path.exists(self.path_sess_dir):
            os.system('rm -rf '+ self.path_sess_dir)
    
    def test_get_prop(self):
        el = self.prop.get('var')
        self.assertEqual(el, 'value')
        
    def test_get_error(self):
        el = self.prop.get('var_not_exist')
        self.assertEqual(el, None)
    
    def test_get_prop_sess(self):
        el = self.prop_sess.get('var', 'test')
        self.assertEqual(el, 45)
        
    def test_get_error_sess(self):
        el = self.prop_sess.get('var_not_exist')
        self.assertEqual(el, None)
コード例 #2
0
ファイル: tests.py プロジェクト: hacklabcz/pearl
    def setUp(self):
        self.path = '/tmp/prop_file'
        f = open(self.path, 'w')
        f.write('# qst e\' una prova\n')
        f.write('var = "value"')
        f.close()
        self.prop = Property(self.path)

        self.path_sess = '/tmp/prop_file_session'
        self.path_sess_dir = '/tmp/prop_file_session.d'
        f = open(self.path_sess, 'w')
        f.write('# qst e\' una prova\n')
        f.close()
        os.mkdir(self.path_sess_dir)
        f_s = open(self.path_sess_dir + '/test', 'w')
        f_s.write('var = 45')
        f_s.close()
        self.prop_sess = Property(self.path_sess, True)
コード例 #3
0
ファイル: tests.py プロジェクト: hacklabcz/pearl
 def setUp(self):
     self.path = '/tmp/prop_file'
     f = open(self.path, 'w')
     f.write('# qst e\' una prova\n')
     f.write('var = "value"')
     f.close()
     self.prop = Property(self.path)
     
     self.path_sess = '/tmp/prop_file_session'
     self.path_sess_dir = '/tmp/prop_file_session.d'
     f = open(self.path_sess, 'w')
     f.write('# qst e\' una prova\n')
     f.close()
     os.mkdir(self.path_sess_dir)
     f_s = open(self.path_sess_dir+'/test', 'w')
     f_s.write('var = 45')
     f_s.close()
     self.prop_sess = Property(self.path_sess, True)
コード例 #4
0
ファイル: tests.py プロジェクト: hacklabcz/pearl
class PropertyTestCase(unittest.TestCase):
    def setUp(self):
        self.path = '/tmp/prop_file'
        f = open(self.path, 'w')
        f.write('# qst e\' una prova\n')
        f.write('var = "value"')
        f.close()
        self.prop = Property(self.path)

        self.path_sess = '/tmp/prop_file_session'
        self.path_sess_dir = '/tmp/prop_file_session.d'
        f = open(self.path_sess, 'w')
        f.write('# qst e\' una prova\n')
        f.close()
        os.mkdir(self.path_sess_dir)
        f_s = open(self.path_sess_dir + '/test', 'w')
        f_s.write('var = 45')
        f_s.close()
        self.prop_sess = Property(self.path_sess, True)

    def tearDown(self):
        """
        Deletes the file for the next tests.
        """
        if os.path.exists(self.path):
            os.system('rm ' + self.path)
        if os.path.exists(self.path_sess_dir):
            os.system('rm -rf ' + self.path_sess_dir)

    def test_get_prop(self):
        el = self.prop.get('var')
        self.assertEqual(el, 'value')

    def test_get_error(self):
        el = self.prop.get('var_not_exist')
        self.assertEqual(el, None)

    def test_get_prop_sess(self):
        el = self.prop_sess.get('var', 'test')
        self.assertEqual(el, 45)

    def test_get_error_sess(self):
        el = self.prop_sess.get('var_not_exist')
        self.assertEqual(el, None)