def test_load_with_file(self): config = self.default_config config["foo"] = "bar" with open(self.folder+"bmc.json", 'w') as fh: json.dump(config, fh) config_read = Config(base_config_path=self.folder) self.assertEqual(config, config_read.as_dict())
def test_load_with_file(self): config = self.default_config config["foo"] = "bar" with open(self.folder + "bmc.json", 'w') as fh: json.dump(config, fh) config_read = Config(base_config_path=self.folder) self.assertEqual(config, config_read.as_dict())
def test_save(self): config = Config(base_config_path=self.folder) config.set("foo", "bar") config.save() with open(self.folder + "bmc.json", 'r') as fh: read = json.loads(fh.read()) self.assertEqual(read, config.as_dict())
def test_save(self): config = Config(base_config_path=self.folder) config.set("foo", "bar") config.save() with open(self.folder+"bmc.json", 'r') as fh: read = json.loads(fh.read()) self.assertEqual(read, config.as_dict())
import argparse import os import shutil import subprocess import sys import tempfile import bibtexparser from codecs import open from libbmc.config import Config from libbmc import backend from libbmc import fetcher from libbmc import tearpages from libbmc import tools config = Config() EDITOR = os.environ.get('EDITOR') if os.environ.get('EDITOR') else 'vim' def checkBibtex(filename, bibtex_string): print("The bibtex entry found for " + filename + " is:") bibtex = bibtexparser.loads(bibtex_string) bibtex = bibtex.entries_dict try: bibtex = bibtex[list(bibtex.keys())[0]] # Check entries are correct if "title" not in bibtex: raise AssertionError if "authors" not in bibtex and "author" not in bibtex: raise AssertionError
import argparse import os import shutil import subprocess import sys import tempfile from bibtexparser.bparser import BibTexParser from codecs import open from libbmc.config import Config from libbmc import backend from libbmc import fetcher from libbmc import tearpages from libbmc import tools config = Config() EDITOR = os.environ.get('EDITOR') if os.environ.get('EDITOR') else 'vim' def checkBibtex(filename, bibtex_string): print("The bibtex entry found for "+filename+" is:") bibtex = BibTexParser(bibtex_string) bibtex = bibtex.get_entry_dict() try: bibtex = bibtex[list(bibtex.keys())[0]] # Check entries are correct assert bibtex['title'] if bibtex['type'] == 'article': assert bibtex['authors'] elif bibtex['type'] == 'book':
def test_masks(self): with open(self.folder+"masks.py", 'w') as fh: fh.write("def f(x): return x") config = Config(base_config_path=self.folder) self.assertEqual("foo", config.get("format_custom")[0]("foo"))
def test_set(self): config = Config(base_config_path=self.folder) config.set("foo", "bar") self.assertEqual(config.get("foo"), "bar")
def test_get(self): config = Config(base_config_path=self.folder) self.assertEqual(config.get("proxies"), [''])
def test_load_without_file(self): config = Config(base_config_path=self.folder) self.assertEqual(config.as_dict(), self.default_config) with open(self.folder+"bmc.json", 'r') as fh: read = json.loads(fh.read()) self.assertEqual(read, self.default_config)
def test_masks(self): with open(self.folder + "masks.py", 'w') as fh: fh.write("def f(x): return x") config = Config(base_config_path=self.folder) self.assertEqual("foo", config.get("format_custom")[0]("foo"))
def test_load_without_file(self): config = Config(base_config_path=self.folder) self.assertEqual(config.as_dict(), self.default_config) with open(self.folder + "bmc.json", 'r') as fh: read = json.loads(fh.read()) self.assertEqual(read, self.default_config)