# Path: rosrepo.py



import unittest
import sys
import os
import shutil
from tempfile import mkdtemp
from distutils.version import StrictVersion
from rosrepo.config import Config, ConfigError
from rosrepo import __version__ as rosrepo_version
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write(":[::] GARBAGE")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("no_version: yes")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("version: invalid")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("version: 123")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("version: %s" % rosrepo_version)
        cfg = Config(self.wsdir)
        os.chmod(cfg_file, 0)
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        os.chmod(cfg_file, 0o644)
        os.chmod(cfg_dir, 0)
        self.assertRaises(ConfigError, cfg.write)
        os.chmod(cfg_dir, 0o755)

    def test_version_mismatch(self):
        """Test handling of configuration files from different rosrepo versions"""
        os.makedirs(os.path.join(self.wsdir, ".rosrepo"))
        cfg_file = os.path.join(self.wsdir, ".rosrepo", "config")
        with open(cfg_file, "w") as f:
            f.write("version: %s" % rosrepo_version)
        cfg = Config(self.wsdir)

# Path: rosrepo.py



# Path: test/test_config.py
import unittest
import sys
import os
import shutil
from tempfile import mkdtemp
from distutils.version import StrictVersion
from rosrepo.config import Config, ConfigError
from rosrepo import __version__ as rosrepo_version

        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write(":[::] GARBAGE")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("no_version: yes")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("version: invalid")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("version: 123")
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        with open(cfg_file, "w") as f:
            f.write("version: %s" % rosrepo_version)
        cfg = Config(self.wsdir)
        os.chmod(cfg_file, 0)
        self.assertRaises(ConfigError, lambda: Config(self.wsdir))
        os.chmod(cfg_file, 0o644)
        os.chmod(cfg_dir, 0)
        self.assertRaises(ConfigError, cfg.write)
        os.chmod(cfg_dir, 0o755)

    def test_version_mismatch(self):
        """Test handling of configuration files from different rosrepo versions"""
        os.makedirs(os.path.join(self.wsdir, ".rosrepo"))
        cfg_file = os.path.join(self.wsdir, ".rosrepo", "config")
        with open(cfg_file, "w") as f:
            f.write("version: %s" % rosrepo_version)
        cfg = Config(self.wsdir)

        self.assertEqual(cfg.get("version"), rosrepo_version)