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. 5
      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
section to use;
- argument: unused;
- contentlist: a list of one or two strings, which are the names (short
and long) of the section;
- contentlist: a list of one or two strings, which are the names (long
and short) of the section;
- config: configuration dictionary of the current songbook.
"""
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"]

5
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')
return files.path2posix(files.relpath(elem.song.fullpath, songpath))
elif isinstance(elem, Section):
return "{}:{}".format(elem.keyword, elem.name)
if elem.short is None:
return "{}:{}".format(elem.keyword, elem.name)
else:
return "{}:({}){}".format(elem.keyword, elem.short, elem.name)
else:
raise Exception(elem)

Loading…
Cancel
Save