def test_add_aspath(): config = Config() new_file = open(CONFIG_FILENAME, "w") new_file.write("[this]\n\tthat = true\n") new_file.close() config.add_file(Path(CONFIG_FILENAME), 0) assert 'this.that' in config
def test_add(self): config = Config() new_file = open(CONFIG_FILENAME, "w") new_file.write("[this]\n\tthat = true\n") new_file.write("[something \"other\"]\n\there = false") new_file.close() config.add_file(CONFIG_FILENAME, 0) assert 'this.that' in config assert config.get_bool('this.that') assert 'something.other.here' in config assert not config.get_bool('something.other.here')
def test_add(self): config = Config() new_file = open(CONFIG_FILENAME, "w") new_file.write("[this]\n\tthat = true\n") new_file.write('[something "other"]\n\there = false') new_file.close() config.add_file(CONFIG_FILENAME, 0) self.assertTrue("this.that" in config) self.assertTrue(config["this.that"]) self.assertTrue("something.other.here" in config) self.assertFalse(config["something.other.here"])
def test_add(self): config = Config() new_file = open(CONFIG_FILENAME, "w") new_file.write("[this]\n\tthat = true\n") new_file.write("[something \"other\"]\n\there = false") new_file.close() config.add_file(CONFIG_FILENAME, 0) self.assertTrue('this.that' in config) self.assertTrue(config['this.that']) self.assertTrue('something.other.here' in config) self.assertFalse(config['something.other.here'])
def test_new(self): # Touch file open(CONFIG_FILENAME, 'w').close() config_write = Config(CONFIG_FILENAME) assert config_write is not None config_write['core.bare'] = False config_write['core.editor'] = 'ed' config_read = Config(CONFIG_FILENAME) assert 'core.bare' in config_read assert not config_read.get_bool('core.bare') assert 'core.editor' in config_read assert config_read['core.editor'] == 'ed'
def test_new(self): # Touch file open(CONFIG_FILENAME, 'w').close() config_write = Config(CONFIG_FILENAME) self.assertNotEqual(config_write, None) config_write['core.bare'] = False config_write['core.editor'] = 'ed' config_read = Config(CONFIG_FILENAME) self.assertTrue('core.bare' in config_read) self.assertFalse(config_read.get_bool('core.bare')) self.assertTrue('core.editor' in config_read) self.assertEqual(config_read['core.editor'], 'ed')
def add_version_commit(): repo = Repository(script_dir) create_commit(repo, 'Update to {}'.format(ver_str)) config = Config.get_global_config() author = Signature(config['user.name'], config['user.email']) repo.create_tag('v{}'.format(ver_str), repo.revparse_single('HEAD').id, GIT_OBJ_COMMIT, author, 'v{}'.format(ver_str))
def create_commit(repo, msg): index = repo.index index.add_all() index.write() config = Config.get_global_config() author = Signature(config['user.name'], config['user.email']) commiter = author tree = index.write_tree() repo.create_commit('refs/heads/master', author, commiter, msg, tree, [repo.head.get_object().hex])
def create_commit(repo_path): repo = Repository (repo_path) index = repo.index index.add_all () index.write () config = Config.get_global_config() author = Signature(config['user.name'], config['user.email']) commiter = author tree = index.write_tree() repo.create_commit ('refs/heads/master', author, commiter, 'Update DSpellCheck to {}'.format (ver), tree, [repo.head.get_object().hex])
def test_add(): with open(CONFIG_FILENAME, "w") as new_file: new_file.write("[this]\n\tthat = true\n") new_file.write("[something \"other\"]\n\there = false") config = Config() config.add_file(CONFIG_FILENAME, 0) assert 'this.that' in config assert config.get_bool('this.that') assert 'something.other.here' in config assert not config.get_bool('something.other.here')
def test_system_config(self): try: assert Config.get_system_config() is not None except IOError: # There is no system config pass
def test_global_config(self): try: assert Config.get_global_config() is not None except IOError: # There is no user config pass
def test_parsing(self): assert Config.parse_bool("on") assert Config.parse_bool("1") assert 5 == Config.parse_int("5") assert 1024 == Config.parse_int("1k")
def test_system_config(self): try: self.assertNotEqual(None, Config.get_system_config()) except IOError: # There is no system config pass
def test_global_config(self): try: self.assertNotEqual(None, Config.get_global_config()) except IOError: # There is no user config pass
def add_version_commit(): repo = Repository(script_dir) create_commit(repo, 'Update to {}'.format(ver_str)) config = Config.get_global_config() author = Signature(config['user.name'], config['user.email'])
def test_parsing(self): self.assertTrue(Config.parse_bool("on")) self.assertTrue(Config.parse_bool("1")) self.assertEqual(5, Config.parse_int("5")) self.assertEqual(1024, Config.parse_int("1k"))
validate_data['DSpellCheck'] = {} validate_data['DSpellCheck'][hashlib.md5( open(x64_binary_path, 'rb').read()).hexdigest()] = 'DSpellCheck.dll' str_after = json.dumps(validate_data['DSpellCheck']) validate_text = validate_text.replace(str_before[1:-1], str_after[1:-1]) with open(validate_path, "w", encoding='utf-8') as file: file.write(validate_text) print('Creating commit in npp-plugins-x64 repository...') repo = Repository(plugins_x64_path) index = repo.index index.add_all() index.write() config = Config.get_global_config() author = Signature(config['user.name'], config['user.email']) commiter = author tree = index.write_tree() repo.create_commit('refs/heads/master', author, commiter, 'Update DSpellCheck to {}'.format(ver), tree, [repo.head.get_object().hex]) else: print('%NPP_PLUGINS_X64_PATH% is not set up, nothing to update') successString = 'Success!' try: from colorama import init, Fore, Style init() successString = Fore.GREEN + Style.BRIGHT + successString except:
def test_multivar(): with open(CONFIG_FILENAME, "w") as new_file: new_file.write("[this]\n\tthat = foobar\n\tthat = foobeer\n") config = Config() config.add_file(CONFIG_FILENAME, 6) assert 'this.that' in config l = list(config.get_multivar('this.that')) assert ['foobar', 'foobeer'] == l l = list(config.get_multivar('this.that', 'bar')) assert ['foobar'] == l l = list(config.get_multivar('this.that', 'foo.*')) assert ['foobar', 'foobeer'] == l config.set_multivar('this.that', '^.*beer', 'fool') l = list(config.get_multivar('this.that', 'fool')) assert ['fool'] == l config.set_multivar('this.that', 'foo.*', 'foo-123456') l = list(config.get_multivar('this.that', 'foo.*')) assert ['foo-123456', 'foo-123456'] == l config.delete_multivar('this.that', 'bar') l = list(config.get_multivar('this.that', '')) assert ['foo-123456', 'foo-123456'] == l config.delete_multivar('this.that', 'foo-[0-9]+') l = list(config.get_multivar('this.that', '')) assert [] == l