Пример #1
0
    def test_missing_file(self, mock1):
        try:
            params = config.read_config("nofile")
            params = config.read_xml_config("nofile")
            self.fail("Should have thrown IOError")
        except IOError as e:
            if "could not find file" not in e.message:
                assert 0

        try:
            params = config.read_xml_config("nofile")
            self.fail("Should have thrown IOError")
        except IOError as e:
            if "could not find file" not in e.message:
                assert 0
	def test_missing_file(self, mock1):
		try:
			params = config.read_config('nofile')
			params = config.read_xml_config('nofile')
			self.fail('Should have thrown IOError')
		except IOError as e:
			if 'Could not find file' not in str(e):
				assert 0
				
		try:
			params = config.read_xml_config('nofile')
			self.fail('Should have thrown IOError')
		except IOError as e:
			if 'Could not find file' not in str(e):
				assert 0
Пример #3
0
 def test_xml_tree(self, mock1):
     try:
         conf = config.read_xml_config("res/config/test-conf-1.xml")
         print(conf.keys())
         for i in range(1, 5):
             assert conf["name.prop." + str(i)] == "val" + str(i)
     except IOError as e:
         self.fail(e)
	def test_xml_tree(self, mock1):
		try:
			conf = config.read_xml_config('res/config/test-conf-1.xml')
			print(conf.keys())
			for i in range(1, 5):
				assert (conf['name.prop.' + str(i)] == 'val' + str(i))
		except IOError as e:
			self.fail(e)
Пример #5
0
    def test_bad_xml_tree(self, mock1):
        try:
            conf = config.read_xml_config("res/config/test-conf-3.xml")
            for i in range(3, 5):
                assert conf["name.prop." + str(i)] == "val" + str(i)
            try:
                v = conf["name.prop.1"]
                self.fail("Should have thrown KeyError")
            except KeyError as e:
                pass
            try:
                v = conf["name.prop.2"]
                self.fail("Should have thrown KeyError")
            except KeyError as e:
                pass

        except IOError as e:
            self.fail(e)
	def test_bad_xml_tree(self, mock1):
		try:
			conf = config.read_xml_config('res/config/test-conf-3.xml')
			for i in range(3, 5):
				assert (conf['name.prop.' + str(i)] == 'val' + str(i))
			try:
				v = conf['name.prop.1']
				self.fail('Should have thrown KeyError')
			except KeyError as e:
				pass
			try:
				v = conf['name.prop.2']
				self.fail('Should have thrown KeyError')
			except KeyError as e:
				pass
			
		except IOError as e:
			self.fail(e)