示例#1
0
    def test_check_attributes_to_force_same_len(self):
        a = InputFileLoaderCheckerSaver()
        a.a = [4, 5]
        a.c = None
        a._attributes_to_force_same_len = ['a c'.split()]
        a.check_input_attributes()

        assert_equal(a.c, [None, None])
示例#2
0
    def test_check_zero_or_all(self):
        a = InputFileLoaderCheckerSaver()
        a.a = 4
        a.b = 6
        a.c = None
        a._zero_or_all = ['a b c'.split()]

        assert_raises(ValueError, a.check_input_attributes)
示例#3
0
    def test_check_attributes_to_force_same_len(self):
        a = InputFileLoaderCheckerSaver()
        a.a = [4,5]
        a.c=None
        a._attributes_to_force_same_len = ['a c'.split()]
        a.check_input_attributes()

        assert_equal(a.c, [None, None])
示例#4
0
    def test_check_zero_or_all(self):
        a = InputFileLoaderCheckerSaver()
        a.a=4
        a.b=6
        a.c=None
        a._zero_or_all = ['a b c'.split()]

        assert_raises(ValueError, a.check_input_attributes)
示例#5
0
    def test_check_attributes_that_should_be_lists(self):
        a = InputFileLoaderCheckerSaver()
        a.a = 4
        a.b = 6
        a._attributes_that_should_be_lists = ['b']
        a.check_input_attributes()

        assert_equal(a.a, 4)
        assert_equal(a.b, [6])
示例#6
0
    def test_check_attributes_that_should_be_lists(self):
        a = InputFileLoaderCheckerSaver()
        a.a=4
        a.b=6
        a._attributes_that_should_be_lists = ['b']
        a.check_input_attributes()

        assert_equal(a.a, 4)
        assert_equal(a.b, [6])
示例#7
0
    def test_save_data_parsed(self):
        a = InputFileLoaderCheckerSaver()
        a._attributes = "a b ".split()
        a.save_data_to_file=True
#        a._initialize_attributes()
        a.a=4
        a.b=6

        a._save_data()
#        print(os.listdir(self.tempdir.path))
#        print(os.listdir(os.path.join(self.tempdir.path,'out0002')))
        assert_equal(self.tempdir.read(
                ('out0002','out0002_input_parsed.py'), 'utf-8').strip().splitlines(),
                     'a = 4\nb = 6'.splitlines())
示例#8
0
    def test_save_data_parsed(self):
        a = InputFileLoaderCheckerSaver()
        a._attributes = "a b ".split()
        a.save_data_to_file=True
#        a._initialize_attributes()
        a.a=4
        a.b=6

        a._save_data()
#        print(os.listdir(self.tempdir.path))
#        print(os.listdir(os.path.join(self.tempdir.path,'out0002')))
        assert_equal(self.tempdir.read(
                ('out0002','out0002_input_parsed.py'), 'utf-8').strip().splitlines(),
                     'a = 4\nb = 6'.splitlines())
示例#9
0
 def test_check_attributes_that_should_have_same_len_pairs(self):
     a = InputFileLoaderCheckerSaver()
     a.a = [2, 3]
     a.c = [3]
     a._attributes_that_should_have_same_len_pairs = ['a c'.split()]
     assert_raises(ValueError, a.check_input_attributes)
示例#10
0
 def test_check_attributes_that_should_have_same_x_limits(self):
     a = InputFileLoaderCheckerSaver()
     a.a = PolyLine([0, 1], [2, 5])
     a.c = PolyLine([0, 7], [5, 6])
     a._attributes_that_should_have_same_x_limits = ['a c'.split()]
     assert_raises(ValueError, a.check_input_attributes)
示例#11
0
 def test_check_one_implies_others(self):
     a = InputFileLoaderCheckerSaver()
     a.a = 4
     a.c = None
     a._one_implies_others = ['a c'.split()]
     assert_raises(ValueError, a.check_input_attributes)
示例#12
0
 def test_check_attributes_that_should_have_same_len_pairs(self):
     a = InputFileLoaderCheckerSaver()
     a.a = [2, 3]
     a.c = [3]
     a._attributes_that_should_have_same_len_pairs = ['a c'.split()]
     assert_raises(ValueError, a.check_input_attributes)
示例#13
0
 def test_check_attributes_that_should_have_same_x_limits(self):
     a = InputFileLoaderCheckerSaver()
     a.a = PolyLine([0,1], [2,5])
     a.c = PolyLine([0,7], [5,6])
     a._attributes_that_should_have_same_x_limits = ['a c'.split()]
     assert_raises(ValueError, a.check_input_attributes)
示例#14
0
 def test_check_one_implies_others(self):
     a = InputFileLoaderCheckerSaver()
     a.a = 4
     a.c=None
     a._one_implies_others = ['a c'.split()]
     assert_raises(ValueError, a.check_input_attributes)