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:

Six Agile Team Behaviors to Consider

Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!

Running Tests In Cypress With GitHub Actions [Complete Guide]

In today’s tech world, where speed is the key to modern software development, we should aim to get quick feedback on the impact of any change, and that is where CI/CD comes in place.

7 Skills of a Top Automation Tester in 2021

With new-age project development methodologies like Agile and DevOps slowly replacing the old-age waterfall model, the demand for testing is increasing in the industry. Testers are now working together with the developers and automation testing is vastly replacing manual testing in many ways. If you are new to the domain of automation testing, the organization that just hired you, will expect you to be fast, think out of the box, and able to detect bugs or deliver solutions which no one thought of. But with just basic knowledge of testing, how can you be that successful test automation engineer who is different from their predecessors? What are the skills to become a successful automation tester in 2019? Let’s find out.

Getting Started with SpecFlow Actions [SpecFlow Automation Tutorial]

With the rise of Agile, teams have been trying to minimize the gap between the stakeholders and the development team.

How To Test React Native Apps On iOS And Android

As everyone knows, the mobile industry has taken over the world and is the fastest emerging industry in terms of technology and business. It is possible to do all the tasks using a mobile phone, for which earlier we had to use a computer. According to Statista, in 2021, smartphone vendors sold around 1.43 billion smartphones worldwide. The smartphone penetration rate has been continuously rising, reaching 78.05 percent in 2020. By 2025, it is expected that almost 87 percent of all mobile users in the United States will own a smartphone.

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