How to use render_body method in Selene

Best Python code snippet using selene_python

test_render.py

Source: test_render.py Github

copy

Full Screen

...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>"...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Migrating Test Automation Suite To Cypress 10

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.

How To Handle Multiple Windows In Selenium Python

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.

Testing Modern Applications With Playwright ????

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 Optimization for Continuous Integration

โ€œ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.

Unveiling Samsung Galaxy Z Fold4 For Mobile App Testing

Hey LambdaTesters! Weโ€™ve got something special for you this week. ????

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selene automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful