Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvin Wan committed Nov 17, 2017
1 parent 21f6d07 commit c40f8d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/test_tex2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def iscream():

def test_basic_prop(chikin):
"""tests that custom __getattr__ works"""
assert str(chikin) == ''
assert str(chikin) == '[document]'
assert chikin.depth == 0
assert len(chikin.branches) == 2
assert isinstance(chikin.section, TreeOfContents)
Expand Down
9 changes: 4 additions & 5 deletions tex2py/tex2py.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from TexSoup import TexSoup, TexNode
from pptree import print_tree


class TreeOfContents(object):
"""Tree abstraction for latex source"""

Expand Down Expand Up @@ -142,9 +141,9 @@ def expandDescendants(self, branches=None):
>>> toc = TOC.fromLatex(r'\section{h1}\subsection{subh1}\section{h2}\
... \subsection{subh2}')
>>> len(list(toc.source.descendants))
8
9
>>> len(toc.descendants)
8
9
"""
branches = branches or self.branches
return sum([b.descendants for b in branches], []) + \
Expand Down Expand Up @@ -186,11 +185,11 @@ def __getattr__(self, attr, *default):
return self.source
return getattr(self.source, attr, *default)
if attr in self.valid_tags:
return next(filter(lambda t: t.name == attr, self.branches), None)
return next(filter(lambda t: t.source.name == attr, self.branches), None)
if len(default):
return default[0]
if attr[-1] == 's' and tag in self.valid_tags:
condition = lambda t: t.name == tag
condition = lambda t: t.source.name == tag
return filter(condition, self.branches)
raise AttributeError("'TreeOfContents' object has no attribute '%s'" % attr)

Expand Down

0 comments on commit c40f8d6

Please sign in to comment.