Skip to content

Commit

Permalink
Merge 30128c8 into 45916fe
Browse files Browse the repository at this point in the history
  • Loading branch information
Navneet78 committed Oct 8, 2019
2 parents 45916fe + 30128c8 commit 0972858
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
14 changes: 10 additions & 4 deletions tempy/tempy.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,17 @@ def clone(self):
return copy(self)

@classmethod
def join(cls, list):
n = len(list)
def join(cls, list_ele):
n = len(list_ele)
for index in range(1, 2*n-2, 2):
list.insert(index, cls())
return list
list_ele.insert(index, cls())
return list_ele

@classmethod
def map(cls, list_ele):
mapped_list = [cls()(ele) for ele in list_ele]
return mapped_list



class Escaped(DOMElement):
Expand Down
15 changes: 11 additions & 4 deletions tests/test_DOMElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from tempy.elements import Tag
from tempy.exceptions import WrongContentError, WrongArgsError, TagError, DOMModByKeyError, DOMModByIndexError
from tempy.tags import Div, A, P, Html, Head, Body, Pre, Br
from tempy.tags import Div, A, P, Html, Head, Body, Pre, Br, Td
from tempy.tempy import DOMElement, Escaped


Expand Down Expand Up @@ -578,7 +578,14 @@ def test_find(self):
self.assertEqual(len(result), 1)

def test_join(self):
tag= Div()
list=['foo', 'Br', 'Div', 'Pre']
result= tag.join(list)
tag = Div()
list_ele = ['foo', 'Br', 'Div', 'Pre']
result = tag.join(list_ele)
self.assertEqual(len(result), 7)

def test_map(self):
tag = Td()
list_ele = ['foo', 'Br', 'Div', 'Pre']
result = tag.map(list_ele)
self.assertEqual(len(result), 4)

0 comments on commit 0972858

Please sign in to comment.