Best Python code snippet using selene_python
test_render.py
Source: test_render.py
...10@ddt.ddt11class RenderBodyTest(TestCase):12 """Tests for render_body"""13 def test_empty(self):14 self.assertEqual(render_body(""), "")15 @ddt.data(16 ("*", "em"),17 ("**", "strong"),18 ("`", "code"),19 )20 @ddt.unpack21 def test_markdown_inline(self, delimiter, tag):22 self.assertEqual(23 render_body(u"{delimiter}some text{delimiter}".format(delimiter=delimiter)),24 u"<p><{tag}>some text</โ{tag}></โp>".format(tag=tag)25 )26 @ddt.data(27 "b", "blockquote", "code", "del", "dd", "dl", "dt", "em", "h1", "h2", "h3", "i", "kbd",28 "li", "ol", "p", "pre", "s", "sup", "sub", "strong", "strike", "ul"29 )30 def test_openclose_tag(self, tag):31 raw_body = "<{tag}>some text</โ{tag}>".format(tag=tag)32 is_inline_tag = tag in ["b", "code", "del", "em", "i", "kbd", "s", "sup", "sub", "strong", "strike"]33 rendered_body = _add_p_tags(raw_body) if is_inline_tag else raw_body34 self.assertEqual(render_body(raw_body), rendered_body)35 @ddt.data("br", "hr")36 def test_selfclosing_tag(self, tag):37 raw_body = "<{tag}>".format(tag=tag)38 is_inline_tag = tag == "br"39 rendered_body = _add_p_tags(raw_body) if is_inline_tag else raw_body40 self.assertEqual(render_body(raw_body), rendered_body)41 @ddt.data("http", "https", "ftp")42 def test_allowed_a_tag(self, protocol):43 raw_body = '<a href="{protocol}:/โ/โfoo" title="bar">baz</โa>'.format(protocol=protocol)44 self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))45 def test_disallowed_a_tag(self):46 raw_body = '<a href="gopher:/โ/โfoo">link content</โa>'47 self.assertEqual(render_body(raw_body), "<p>link content</โp>")48 @ddt.data("http", "https")49 def test_allowed_img_tag(self, protocol):50 raw_body = '<img src="{protocol}:/โ/โfoo" width="111" height="222" alt="bar" title="baz">'.format(51 protocol=protocol52 )53 self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))54 def test_disallowed_img_tag(self):55 raw_body = '<img src="gopher:/โ/โfoo">'56 self.assertEqual(render_body(raw_body), "<p></โp>")57 def test_script_tag(self):58 raw_body = '<script type="text/โjavascript">alert("evil script");</โscript>'59 self.assertEqual(render_body(raw_body), 'alert("evil script");')60 @ddt.data("p", "br", "li", "hr") # img is tested above61 def test_allowed_unpaired_tags(self, tag):62 raw_body = "foo<{tag}>bar".format(tag=tag)63 self.assertEqual(render_body(raw_body), _add_p_tags(raw_body))64 def test_unpaired_start_tag(self):65 self.assertEqual(render_body("foo<i>bar"), "<p>foobar</โp>")66 def test_unpaired_end_tag(self):67 self.assertEqual(render_body("foo</โi>bar"), "<p>foobar</โp>")68 def test_interleaved_tags(self):69 self.assertEqual(70 render_body("foo<i>bar<b>baz</โi>quux</โb>greg"),71 "<p>foo<i>barbaz</โi>quuxgreg</โp>"...
Check out the latest blogs from LambdaTest on this topic:
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.
Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.
โTest frequently and early.โ If youโve been following my testing agenda, youโre probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. Iโve encountered several teams who have a lot of automated tests but donโt use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
Hey LambdaTesters! Weโve got something special for you this week. ????
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!