Browse Source

Improve section content test

pull/179/head
Oliverpool 9 years ago
parent
commit
3314525d9b
  1. 4
      patacrep/content/section.py
  2. 1
      test/test_content/sections_short.control
  3. 6
      test/test_content/sections_short.source
  4. 3
      test/test_content/test_content.py

4
patacrep/content/section.py

@ -37,8 +37,8 @@ def parse(keyword, argument, contentlist, config):
their starred versions "part*", "chapter*", ... , "subparagraph*"): the their starred versions "part*", "chapter*", ... , "subparagraph*"): the
section to use; section to use;
- argument: unused; - argument: unused;
- contentlist: a list of one or two strings, which are the names (short - contentlist: a list of one or two strings, which are the names (long
and long) of the section; and short) of the section;
- config: configuration dictionary of the current songbook. - config: configuration dictionary of the current songbook.
""" """
if (keyword not in KEYWORDS) and (len(contentlist) != 1): if (keyword not in KEYWORDS) and (len(contentlist) != 1):

1
test/test_content/sections_short.control

@ -0,0 +1 @@
["section:(tradi)Traditional", "exsong.sg", "section:Example", "texsong.tsg", "chordpro.csg", "exsong.sg"]

6
test/test_content/sections_short.source

@ -0,0 +1,6 @@
[["section", "Traditional", "tradi"],
"exsong.sg",
["section", "Example"],
"texsong.tsg",
"chordpro.csg",
"exsong.sg"]

3
test/test_content/test_content.py

@ -75,7 +75,10 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs') songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs')
return files.path2posix(files.relpath(elem.song.fullpath, songpath)) return files.path2posix(files.relpath(elem.song.fullpath, songpath))
elif isinstance(elem, Section): elif isinstance(elem, Section):
if elem.short is None:
return "{}:{}".format(elem.keyword, elem.name) return "{}:{}".format(elem.keyword, elem.name)
else:
return "{}:({}){}".format(elem.keyword, elem.short, elem.name)
else: else:
raise Exception(elem) raise Exception(elem)

Loading…
Cancel
Save