Exemplo n.º 1
0
    def test_corrupt_config_in_environment(self):
        os.environ["PYFARM_LOGGING_CONFIG"] = '{"foo" "bar"}'

        if PY3:
            with self.assertRaisesRegex(ValueError, "Failed to parse json data from \$PYFARM_LOGGING_CONFIG"):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        else:
            with self.assertRaises(ValueError):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
Exemplo n.º 2
0
    def test_corrupt_config_in_environment(self):
        os.environ["PYFARM_LOGGING_CONFIG"] = '{"foo" "bar"}'

        if PY3:
            with self.assertRaisesRegex(
                    ValueError,
                    "Failed to parse json data from \$PYFARM_LOGGING_CONFIG"):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        else:
            with self.assertRaises(ValueError):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
Exemplo n.º 3
0
    def test_corrupt_config_file(self):
        _, path = tempfile.mkstemp()

        with open(path, "w") as stream:
            stream.write('{"foo" "bar"}')

        os.environ["PYFARM_LOGGING_CONFIG"] = path

        if PY3:
            with self.assertRaisesRegex(ValueError, "Failed to parse json data from %s" % path):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        else:
            with self.assertRaises(ValueError):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        self.remove(path)
Exemplo n.º 4
0
    def test_corrupt_config_file(self):
        _, path = tempfile.mkstemp()

        with open(path, "w") as stream:
            stream.write('{"foo" "bar"}')

        os.environ["PYFARM_LOGGING_CONFIG"] = path

        if PY3:
            with self.assertRaisesRegex(
                    ValueError, "Failed to parse json data from %s" % path):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        else:
            with self.assertRaises(ValueError):
                self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        self.remove(path)
Exemplo n.º 5
0
    def test_config_file(self):
        _, path = tempfile.mkstemp()

        with open(path, "w") as stream:
            stream.write(json.dumps(config.DEFAULT_CONFIGURATION.copy()))

        os.environ["PYFARM_LOGGING_CONFIG"] = path
        self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        self.remove(path)
Exemplo n.º 6
0
    def test_config_file(self):
        _, path = tempfile.mkstemp()

        with open(path, "w") as stream:
            stream.write(json.dumps(config.DEFAULT_CONFIGURATION.copy()))

        os.environ["PYFARM_LOGGING_CONFIG"] = path
        self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
        self.remove(path)
Exemplo n.º 7
0
 def test_config_in_environment(self):
     os.environ["PYFARM_LOGGING_CONFIG"] = json.dumps(
         config.DEFAULT_CONFIGURATION)
     self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
Exemplo n.º 8
0
 def test_config_empty(self):
     os.environ["PYFARM_LOGGING_CONFIG"] = ""
     with self.assertRaises(ValueError):
         config.get()
Exemplo n.º 9
0
 def test_config_in_environment(self):
     os.environ["PYFARM_LOGGING_CONFIG"] = json.dumps(config.DEFAULT_CONFIGURATION)
     self.assertEqual(config.get(), config.DEFAULT_CONFIGURATION)
Exemplo n.º 10
0
 def test_config_empty(self):
     os.environ["PYFARM_LOGGING_CONFIG"] = ""
     with self.assertRaises(ValueError):
         config.get()