Ejemplo n.º 1
0
    def invalid_write_test(self):
        parser = create_parser()

        with self.assertRaises(ConfigurationFileError) as cm:
            write_config(parser, "nonexistent/path/to/file")

        self.assertEqual(cm.exception._filename, "nonexistent/path/to/file")
Ejemplo n.º 2
0
    def invalid_write_test(self):
        parser = create_parser()

        with self.assertRaises(ConfigurationFileError) as cm:
            write_config(parser, "nonexistent/path/to/file")

        self.assertEqual(cm.exception._filename, "nonexistent/path/to/file")
        self.assertTrue(str(cm.exception).startswith(
            "The following error has occurred while handling the configuration file"
        ))
Ejemplo n.º 3
0
    def invalid_write_test(self):
        parser = create_parser()

        with self.assertRaises(ConfigurationFileError) as cm:
            write_config(parser, "nonexistent/path/to/file")

        self.assertEqual(cm.exception._filename, "nonexistent/path/to/file")
        self.assertTrue(str(cm.exception).startswith(
            "The following error has occurred while handling the configuration file"
        ))
Ejemplo n.º 4
0
    def test_invalid_write(self):
        parser = create_parser()

        with pytest.raises(ConfigurationFileError) as cm:
            write_config(parser, "nonexistent/path/to/file")

        assert cm.value._filename == "nonexistent/path/to/file"
        assert str(cm.value).startswith(
            "The following error has occurred while handling the configuration file"
        )
Ejemplo n.º 5
0
    def write_test(self):
        parser = create_parser()
        self._read_content(parser)

        with tempfile.NamedTemporaryFile("r+") as f:
            # Write the config file.
            write_config(parser, f.name)
            f.flush()

            # Check the config file.
            self.assertEqual(f.read().strip(), self._content.strip())
Ejemplo n.º 6
0
    def write_test(self):
        parser = create_parser()
        self._read_content(parser)

        with tempfile.NamedTemporaryFile("r+") as f:
            # Write the config file.
            write_config(parser, f.name)
            f.flush()

            # Check the config file.
            self.assertEqual(f.read().strip(), self._content.strip())
Ejemplo n.º 7
0
    def write(self, path):
        """Write a configuration file.

        :param path: a path to the file
        """
        write_config(self._parser, path)