Ejemplo n.º 1
0
 def test_two_distinct_names(self):
     assert all_but_blocks(("first", "blah"), self.tdn_data) \
            == "This is\n\nThis is\n"
     assert all_but_blocks("first", self.tdn_data) \
            == "This is\n\nThis is\n\nsome text\n"
     assert all_but_blocks("blah", self.tdn_data) \
            == "This is\n\nsome text\n\nThis is\n"
Ejemplo n.º 2
0
 def test_two_distinct_names(self):
     assert all_but_blocks(("first", "blah"), self.tdn_data) \
            == "This is\n\nThis is\n"
     assert all_but_blocks("first", self.tdn_data) \
            == "This is\n\nThis is\n\nsome text\n"
     assert all_but_blocks("blah", self.tdn_data) \
            == "This is\n\nsome text\n\nThis is\n"
Ejemplo n.º 3
0
 def test_0_to_2_blocks_with_default_and_custom_newline(self, names):
     assert all_but_blocks(names, self.blockless_data) \
            == "Do you need\n\nsome\nblockless data?"
     assert all_but_blocks(names, self.blockless_data, newline="!!") \
            == "Do you need!!!!some!!blockless data?"
     assert all_but_blocks(names, self.data) \
            == "This is\n"
     assert all_but_blocks(names, self.data, newline="-") \
            == "This is-"
     assert all_but_blocks(names, self.double_data) \
            == "This is\n\nThis is\n"
     assert all_but_blocks(names, self.double_data, newline="-") \
            == "This is--This is-"
     assert all_but_blocks(names, self.double_data, newline="") \
            == "This isThis is"
Ejemplo n.º 4
0
 def test_0_to_2_blocks_with_default_and_custom_newline(self, names):
     assert all_but_blocks(names, self.blockless_data) \
            == "Do you need\n\nsome\nblockless data?"
     assert all_but_blocks(names, self.blockless_data, newline="!!") \
            == "Do you need!!!!some!!blockless data?"
     assert all_but_blocks(names, self.data) \
            == "This is\n"
     assert all_but_blocks(names, self.data, newline="-") \
            == "This is-"
     assert all_but_blocks(names, self.double_data) \
            == "This is\n\nThis is\n"
     assert all_but_blocks(names, self.double_data, newline="-") \
            == "This is--This is-"
     assert all_but_blocks(names, self.double_data, newline="") \
            == "This isThis is"
Ejemplo n.º 5
0
 def test_nested_block_remove_params(self, names):
     args = names, self.nested_data
     kw_remove = {"remove_empty_next": False, "remove_comments": False}
     assert all_but_blocks(*args) \
            == "This is\n\nThis is\n"
     assert all_but_blocks(*args, newline="~") \
            == "This is~~This is~"
     assert all_but_blocks(*args, remove_empty_next=False) \
            == "This is\n\nThis is\n\n"
     assert all_but_blocks(*args, newline="~", remove_empty_next=False) \
            == "This is~~This is~~"
     assert all_but_blocks(*args, remove_comments=False) \
            == "This is\n\n.. outer\n\nThis is\n\n.. outer end"
     assert all_but_blocks(*args, newline="~", remove_comments=False) \
            == "This is~~.. outer~~This is~~.. outer end"
     assert all_but_blocks(*args, **kw_remove) \
            == "This is\n\n.. outer\n\nThis is\n\n\n.. outer end"
     assert all_but_blocks(*args, newline="~", **kw_remove) \
            == "This is~~.. outer~~This is~~~.. outer end"
Ejemplo n.º 6
0
 def test_nested_block_remove_params(self, names):
     args = names, self.nested_data
     kw_remove = {"remove_empty_next": False, "remove_comments": False}
     assert all_but_blocks(*args) \
            == "This is\n\nThis is\n"
     assert all_but_blocks(*args, newline="~") \
            == "This is~~This is~"
     assert all_but_blocks(*args, remove_empty_next=False) \
            == "This is\n\nThis is\n\n"
     assert all_but_blocks(*args, newline="~", remove_empty_next=False) \
            == "This is~~This is~~"
     assert all_but_blocks(*args, remove_comments=False) \
            == "This is\n\n.. outer\n\nThis is\n\n.. outer end"
     assert all_but_blocks(*args, newline="~", remove_comments=False) \
            == "This is~~.. outer~~This is~~.. outer end"
     assert all_but_blocks(*args, **kw_remove) \
            == "This is\n\n.. outer\n\nThis is\n\n\n.. outer end"
     assert all_but_blocks(*args, newline="~", **kw_remove) \
            == "This is~~.. outer~~This is~~~.. outer end"
Ejemplo n.º 7
0
 def test_generator_when_newline_is_none_and_data_is_endless(self):
     result = all_but_blocks("some name", self.endless_data, newline=None)
     assert isinstance(result, collections.Iterator)
     for unused in range(30):
         line = next(result)
         assert line == "again"
Ejemplo n.º 8
0
 def test_generator_when_newline_is_none_and_data_is_endless(self):
     result = all_but_blocks("some name", self.endless_data, newline=None)
     assert isinstance(result, collections.Iterator)
     for unused in range(30):
         line = next(result)
         assert line == "again"