def test_config_cfg_merge(): sources = [Path("path1"), Path("path2")] config = Config(config_file=setup_cfg).parse() console_configuration = { "include": "tests|env", "remove": True, "diff": False, "include_star_import": True, } gitignore_exclude = utils.get_exclude_list_from_gitignore() exclude = "|".join( [config.exclude] + gitignore_exclude + [C.INIT_FILE_IGNORE_REGEX] ) config = config.merge(**console_configuration) assert config.include == "tests|env" assert config.exclude == exclude assert config.sources == sources assert config.gitignore is True assert config.requirements is True assert config.remove is True assert config.diff is False assert config.ignore_init is True
def test_toml_command_check(): config = Config(pyproject).parse() assert config.merge(check=True).check is True assert config.merge(diff=False).check is True assert config.merge(diff=False, permission=False).check is True assert config.merge().check is False assert config.merge(gitignore=True).check is False assert config.merge(diff=True).check is False assert config.merge(remove=True).check is False assert config.merge(permission=True).check is False
class TestTomlCommand(TestCase): def setUp(self): self.config = Config(pyproject).parse() self.exclude = "__init__.py|tests/" def test_same_with_toml_config(self): self.assertEqual( self.config.merge(exclude=self.exclude).exclude, self.config.merge().exclude, ) def test_check(self): self.assertTrue(self.config.merge(check=True).check) self.assertTrue(self.config.merge(diff=False).check) self.assertTrue(self.config.merge(diff=False, permission=False).check) self.assertFalse(self.config.merge().check) self.assertFalse(self.config.merge(gitignore=True).check) self.assertFalse(self.config.merge(diff=True).check) self.assertFalse(self.config.merge(remove=True).check) self.assertFalse(self.config.merge(permission=True).check)
def test_cfg_merge(self): config = Config(config_file=setup_cfg).parse() console_configuration = { "include": "tests|env", "remove": True, "diff": False, "include_star_import": True, } gitignore_exclude = utils.get_exclude_list_from_gitignore() gitignore_exclude.extend(config.exclude) exclude = "|".join(gitignore_exclude) config = config.merge(**console_configuration) self.assertEqual("tests|env", config.include) self.assertEqual(exclude, config.exclude) self.assertEqual(self.sources, config.sources) self.assertTrue(config.gitignore) self.assertTrue(config.requirements) self.assertTrue(config.remove) self.assertFalse(config.diff)
def test_cfg_merge(self): config = Config(config_file=no_unimport_setup_cfg).parse() console_configuration = { "include": "tests|env", "remove": True, "diff": False, "include_star_import": True, } config = config.merge(**console_configuration) self.assertEqual("tests|env", config.include) self.assertEqual(self.default_config.exclude, config.exclude) self.assertEqual(self.default_config.sources, config.sources) self.assertTrue(config.remove) self.assertTrue(config.include_star_import) self.assertFalse(config.gitignore) self.assertFalse(config.requirements) self.assertFalse(config.diff)
def test_no_import_section_cfg_merge(): default_config = DefaultConfig() config = Config(config_file=no_unimport_setup_cfg).parse() console_configuration = { "include": "tests|env", "remove": True, "diff": False, "include_star_import": True, } config = config.merge(**console_configuration) assert config.include == "tests|env" assert default_config.exclude == config.exclude assert default_config.sources == config.sources assert config.remove is True assert config.include_star_import is True assert config.gitignore is False assert config.requirements is False assert config.diff is False
def test_toml_command_same_with_config(): config = Config(pyproject).parse() exclude = "__init__.py|tests/" assert config.merge(exclude=exclude).exclude == config.merge().exclude