def test_was_opened_AND_close_tags(self): stack = [] l1, l2 = layer.Layer(stack), layer.Layer(stack) l1.text = '...' l2.tags, l2.text = {tag_i}, ',,,' self.assertTrue(tag.was_opened(stack, tag_i)) self.assertFalse(tag.was_opened(stack, tag.Tag('c green', 'c'))) layer.close_tags(stack, {tag_i}, len(stack) - 1) expected = [] l = layer.Layer(expected) l.text = '...[i],,,[/i]' self.assertEqual(expected, stack)
def test_was_opened_AND_close_tags(self): stack = [] l1, l2 = layer.Layer(stack), layer.Layer(stack) l1.text = "..." l2.tags, l2.text = {tag_i}, ",,," self.assertTrue(tag.was_opened(stack, tag_i)) self.assertFalse(tag.was_opened(stack, tag.Tag("c green", "c"))) layer.close_tags(stack, {tag_i}, len(stack) - 1) expected = [] l = layer.Layer(expected) l.text = "...[i],,,[/i]" self.assertEqual(expected, stack)
import os import sys from functools import partial sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from flawless_dsl import layer, tag from flawless_dsl.main import ( process_closing_tags, FlawlessDSLParser, parse, BRACKET_L, BRACKET_R, ) tag_i = tag.Tag('i', 'i') tag_m = tag.Tag('m1', 'm') tag_p = tag.Tag('p', 'p') tag_s = tag.Tag('s', 's') class LayerTestCase(unittest.TestCase): def setUp(self): pass def test_new_layer(self): stack = [] l = layer.Layer(stack) self.assertEqual(1, len(stack)) self.assertEqual(l, stack[0])
import os import sys from functools import partial sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from flawless_dsl import layer, tag from flawless_dsl.main import ( process_closing_tags, FlawlessDSLParser, parse, BRACKET_L, BRACKET_R, ) tag_i = tag.Tag("i", "i") tag_m = tag.Tag("m1", "m") tag_p = tag.Tag("p", "p") tag_s = tag.Tag("s", "s") class LayerTestCase(unittest.TestCase): def setUp(self): pass def test_new_layer(self): stack = [] l = layer.Layer(stack) self.assertEqual(1, len(stack)) self.assertEqual(l, stack[0])