def __init__(self): if os.path.isfile(filepather.relative_file_path( __file__, DB_FILE_NAME)): self.open() else: self.open() self.create_tables()
def test_splitting(self): bot = GGGGobblerBot(None, None) path = filepather.relative_file_path(__file__, os.path.join('testdata', 'longpost.txt')) with open(path) as md: staffposts = [StaffPost('abcdef', '123456', 'Bex', md.read(), 'date-test')] posts = bot.create_divided_comments(staffposts) self.assertEqual(len(posts), 7)
def load_values_v2(self, data_name): path = filepather.relative_file_path(__file__, os.path.join("testdata", "convert")) with open(os.path.join(path, data_name + "_input.html"), 'r') as f: # cut off the trailing \n html = f.read()[:-1] with open(os.path.join(path, data_name + "_output.md"), 'r') as f: expected_output = f.read()[:-1] return html, expected_output
def prepare(): logger = logging.getLogger(settings.LOGGER_NAME) fh = logging.FileHandler( filepather.relative_file_path(__file__, 'GGGGobblerVomit.log')) fmt = logging.Formatter('[%(levelname)s] [%(asctime)s]: %(message)s') fh.setFormatter(fmt) logger.addHandler(fh) logger.setLevel(logging.INFO) if not settings.LOGGING_ON: logging.disable(logging.CRITICAL)
def load_md(self, data_name): path = filepather.relative_file_path( __file__, os.path.join("testdata", "markdown")) with open(os.path.join(path, data_name + ".md"), 'r') as f: # cut off trailing \n file_contents = f.read() if file_contents[-1] != "\n": raise TestDataFileFormatException( "Test data files should contain the tested text data following by an extraneous newline character" ) return file_contents[:-1]
def open(self): self.db = sqlite3.connect( filepather.relative_file_path(__file__, DB_FILE_NAME))
def read_ini(): cfg = configparser.ConfigParser() cfg.read(filepather.relative_file_path(__file__, 'oauth.ini')) return cfg
def _get_filename(): return filepather.relative_file_path(__file__, os.path.join(os.pardir, FILENAME))