Browse Source

Restore test_content tests

pull/184/head
Oliverpool 9 years ago
parent
commit
0204919280
  1. 2
      patacrep/content/include.py
  2. 12
      test/test_content/test_content.py

2
patacrep/content/include.py

@ -46,7 +46,7 @@ def parse(keyword, config, argument, contentlist):
try: try:
with encoding.open_read( with encoding.open_read(
filepath, filepath,
encoding=config['encoding'] encoding=config['book']['encoding']
) as content_file: ) as content_file:
new_content = json.load(content_file) new_content = json.load(content_file)
except Exception as error: # pylint: disable=broad-except except Exception as error: # pylint: disable=broad-except

12
test/test_content/test_content.py

@ -2,8 +2,6 @@
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
#pylint: skip-file
import glob import glob
import os import os
import unittest import unittest
@ -11,9 +9,10 @@ import json
import yaml import yaml
from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep.songs import DataSubpath
from patacrep import content, encoding, files, pkg_datapath from patacrep import content, encoding, files, pkg_datapath
from patacrep.content import song, section, songsection, tex from patacrep.content import song, section, songsection, tex
from patacrep.build import config_model
from .. import logging_reduced from .. import logging_reduced
from .. import dynamic # pylint: disable=unused-import from .. import dynamic # pylint: disable=unused-import
@ -35,7 +34,6 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
@classmethod @classmethod
def _iter_testmethods(cls): def _iter_testmethods(cls):
return
"""Iterate over dynamically generated test methods""" """Iterate over dynamically generated test methods"""
for source in sorted(glob.glob(os.path.join( for source in sorted(glob.glob(os.path.join(
os.path.dirname(__file__), os.path.dirname(__file__),
@ -101,14 +99,12 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
"""Generate the config to process the content""" """Generate the config to process the content"""
# Load the default songbook config # Load the default songbook config
default_songbook_path = pkg_datapath('templates', 'default_songbook.sb.yml') config = config_model('default')
with encoding.open_read(default_songbook_path) as default_songbook_file:
config = yaml.load(default_songbook_file)
datadirpaths = [os.path.join(os.path.dirname(__file__), 'datadir')] datadirpaths = [os.path.join(os.path.dirname(__file__), 'datadir')]
# todo : yaml and testing? # todo : yaml and testing?
config['datadir'] = datadirpaths config['_datadir'] = datadirpaths
config['_songdir'] = [ config['_songdir'] = [
DataSubpath(path, 'songs') DataSubpath(path, 'songs')

Loading…
Cancel
Save