Example #1
0
    def test_init_from_str(self):
        a = InputFileLoaderCheckerSaver()
        a._attributes = "a b".split()
        a._initialize_attributes()
        a.__init__('a=4\nb=6')

        assert_equal(a.a, 4)
        assert_equal(a.b, 6)
        assert_equal(a._input_text, 'a=4\nb=6')
Example #2
0
    def test_init_from_str(self):
        a = InputFileLoaderCheckerSaver()
        a._attributes = "a b".split()
        a._initialize_attributes()
        a.__init__('a=4\nb=6')

        assert_equal(a.a, 4)
        assert_equal(a.b, 6)
        assert_equal(a._input_text, 'a=4\nb=6')
Example #3
0
    def test_init_from_fileobj(self):
        a = InputFileLoaderCheckerSaver()
        a._attributes = "a b".split()
        a._initialize_attributes()
        with open(os.path.join(self.tempdir.path, 'inp1.py'), 'r') as f:
            a.__init__(f)

        assert_equal(a.a, 4)
        assert_equal(a.b, 6)
        assert_equal(a._input_text, 'a=4\nb=6')
Example #4
0
    def test_init_from_fileobj(self):
        a = InputFileLoaderCheckerSaver()
        a._attributes = "a b".split()
        a._initialize_attributes()
        with open(os.path.join(self.tempdir.path, 'inp1.py'), 'r') as f:
            a.__init__(f)

        assert_equal(a.a, 4)
        assert_equal(a.b, 6)
        assert_equal(a._input_text, 'a=4\nb=6')
Example #5
0
    def test_attribute_defaults(self):
        a = InputFileLoaderCheckerSaver()
        a._input_text = 'b=6'
        a._attributes = "a b".split()
        a._attribute_defaults = {'a': 24}
        a._initialize_attributes()
        a._transfer_attributes_from_inputfile()

        assert_equal(a.a, 24)
        assert_equal(a.b, 6)
        assert_equal(a._input_text, 'b=6')
Example #6
0
    def test_attribute_defaults(self):
        a = InputFileLoaderCheckerSaver()
        a._input_text = 'b=6'
        a._attributes = "a b".split()
        a._attribute_defaults = {'a': 24}
        a._initialize_attributes()
        a._transfer_attributes_from_inputfile()

        assert_equal(a.a, 24)
        assert_equal(a.b, 6)
        assert_equal(a._input_text, 'b=6')