code: def testSetInvalidFile(self, findConfigFile, environ):
      environ.__getitem__.side_effect = dict(
          NTA_DYNAMIC_CONF_DIR=os.path.dirname(
              self.files["nupic-custom.xml"]
          )
      ).get
      configuration.Configuration.clear()
  
      with open(self.files["nupic-custom.xml"], "w") as fp:
          fp.write(
              "\n".join(
                  (
                      '<?xml version="1.0"?>',
                      '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>',
                      "<foo/>",
                  )
              )
          )
  
      with patch("sys.stderr", new_callable=StringIO):
          with self.assertRaises(RuntimeError) as cm:
              configuration.Configuration.setCustomProperty(
                  "foo", "value"
              )
          self.assertIn(
              "Expected top-level element to be 'configuration'",
              cm.exception.args[0],
          )
  
      with open(self.files["nupic-custom.xml"], "w") as fp:
          fp.write("\n".join(("")))
  
      with patch("sys.stderr", new_callable=StringIO):
          with self.assertRaises(RuntimeError) as cm:
              configuration.Configuration.setCustomProperty(
                  "foo", "value"
              )
          self.assertIn(
              "File contents of custom configuration is corrupt.",
              cm.exception.args[0],
          )
  
      # NTA_CONF_PATH is not being mocked out in this test, so we have to mock out
      # findConfigFile to return the right path to the config file.
      findConfigFile.return_value = self.files["nupic-custom.xml"]
  
      configuration.Configuration.resetCustomConfig()
      configuration.Configuration.setCustomProperty("foo", "value")
      self.assertEqual(
          configuration.Configuration.getCustomDict(), {"foo": "value"}
      )
  
imports: from copy import copy
  import os
  import shutil
  from StringIO import StringIO
  import sys
  import tempfile
  import unittest2
  import uuid
  from pkg_resources import resource_filename
  from mock import Mock, patch
  from pkg_resources import resource_filename
  from xml.parsers.expat import ExpatError
  import nupic
  import nupic.support.configuration_custom
  import configuration_test
label_desc: Use image node_id 10 for calling the ConfigurationCustomTest obj's underlying member method code with example usage: obj.testSetInvalidFile(findConfigFile, environ) without return types