Best Python code snippet using avocado_python
test_is_url.py
Source: test_is_url.py
1from unittest import TestCase2from string_utils import is_url3class IsUrlTestCase(TestCase):4 def test_should_return_false_for_non_string_objects(self):5 self.assertFalse(is_url(None))6 self.assertFalse(is_url(False))7 self.assertFalse(is_url(0))8 self.assertFalse(is_url([]))9 self.assertFalse(is_url({'a': 1}))10 def test_string_cannot_be_blank(self):11 self.assertFalse(is_url(''))12 self.assertFalse(is_url(' '))13 def test_string_cannot_contain_spaces(self):14 self.assertFalse(is_url(' http:/​/​www.google.com'))15 self.assertFalse(is_url('http:/​/​www.google.com '))16 self.assertFalse(is_url('http:/​/​www.google.com/​ ncr'))17 self.assertFalse(is_url('http:/​/​www.goo gle.com'))18 def test_scheme_is_required(self):19 self.assertFalse(is_url('google.com'))20 self.assertFalse(is_url('www.google.com'))21 def test_domain_extension_is_required_for_named_urls(self):22 self.assertFalse(is_url('http:/​/​google'))23 self.assertFalse(is_url('http:/​/​google.'))24 def test_domain_extension_should_be_between_2_and_6_letters(self):25 self.assertFalse(is_url('http:/​/​google.c'))26 self.assertFalse(is_url('http:/​/​google.abcdefghi'))27 def test_should_accept_any_scheme_by_default(self):28 self.assertTrue(is_url('http:/​/​site.com'))29 self.assertTrue(is_url('http:/​/​www.site.com'))30 self.assertTrue(is_url('https:/​/​site.com'))31 self.assertTrue(is_url('https:/​/​www.site.com'))32 self.assertTrue(is_url('ftp:/​/​site.com'))33 self.assertTrue(is_url('git:/​/​site.com'))34 def test_should_restrict_checking_on_provided_schemes(self):35 self.assertTrue(is_url('git:/​/​site.com'))36 self.assertFalse(is_url('git:/​/​site.com', allowed_schemes=['http', 'https']))37 def test_url_cannot_start_with_dot(self):38 self.assertFalse(is_url('http:/​/​.site.com'))39 def test_url_can_contain_dash(self):40 self.assertTrue(is_url('http:/​/​some-site-name.com'))41 def test_url_cannot_start_with_dash(self):42 self.assertFalse(is_url('http:/​/​-site.com'))43 def test_url_cannot_start_with_slash(self):44 self.assertFalse(is_url('http:/​/​/​www.site.com'))45 def test_www_is_optional(self):46 self.assertTrue(is_url('http:/​/​www.mysite.com'))47 self.assertTrue(is_url('http:/​/​mysite.com'))48 def test_localhost_is_an_accepted_url(self):49 self.assertTrue(is_url('http:/​/​localhost'))50 def test_should_accept_valid_ip_url(self):51 self.assertTrue(is_url('http:/​/​123.123.123.123'))52 self.assertTrue(is_url('http:/​/​1.123.123.123'))53 self.assertTrue(is_url('http:/​/​1.1.123.123'))54 self.assertTrue(is_url('http:/​/​1.1.1.123'))55 self.assertTrue(is_url('http:/​/​1.1.1.1'))56 self.assertTrue(is_url('http:/​/​123.123.123.1'))57 self.assertTrue(is_url('http:/​/​123.123.1.1'))58 self.assertTrue(is_url('http:/​/​123.1.1.1'))59 def test_should_exclude_invalid_ip(self):60 self.assertFalse(is_url('http:/​/​1.2.3'))61 self.assertFalse(is_url('http:/​/​1.2.3.'))62 self.assertFalse(is_url('http:/​/​123.123.123.1234'))63 self.assertFalse(is_url('http:/​/​.123.123.123.123'))64 self.assertFalse(is_url('http:/​/​123.123.123.123.'))65 self.assertFalse(is_url('http:/​/​123.123...123.123'))66 self.assertFalse(is_url('http:/​/​123..123..123.123'))67 def test_url_can_have_port_number(self):68 self.assertTrue(is_url('http:/​/​localhost:8080'))69 def test_url_can_contain_sub_folders(self):70 self.assertTrue(is_url('http:/​/​www.site.com/​one'))71 self.assertTrue(is_url('http:/​/​www.site.com/​one/​'))72 self.assertTrue(is_url('http:/​/​www.site.com/​one/​two'))73 self.assertTrue(is_url('http:/​/​www.site.com/​one/​two/​'))74 self.assertTrue(is_url('http:/​/​www.site.com/​one/​two/​three/​four/​five/​six'))75 def test_url_can_have_user_and_password(self):76 self.assertTrue(is_url('postgres:/​/​myuser:mypassword@localhost:5432/​mydb'))77 def test_url_can_contain_file_extension(self):78 self.assertTrue(is_url('http:/​/​site.com/​foo/​photo.jpg'))79 self.assertTrue(is_url('http:/​/​site.com/​index.html'))80 def test_file_can_contains_multiple_dots(self):81 self.assertTrue(is_url('http:/​/​site.com/​foo/​file.name.ext'))82 def test_url_can_contain_query_string(self):83 self.assertTrue(is_url('http:/​/​site.com/​foo/​?'))84 self.assertTrue(is_url('http:/​/​site.com/​foo/​?foo'))85 self.assertTrue(is_url('http:/​/​site.com/​foo/​?foo=bar'))86 self.assertTrue(is_url('http:/​/​site.com/​foo/​?foo=bar&baz=1'))87 self.assertTrue(is_url('http:/​/​site.com/​foo/​?foo=bar&baz=1&'))88 def test_url_can_have_hash_part(self):89 self.assertTrue(is_url('http:/​/​site.com/​foo#anchor'))90 self.assertTrue(is_url('http:/​/​site.com/​foo#anchor2-with_several+signs++'))91 def test_a_full_url(self):...
test_url.py
Source: test_url.py
...6from mozfile import is_url7import mozunit8class TestIsUrl(unittest.TestCase):9 """test the is_url function"""10 def test_is_url(self):11 self.assertTrue(is_url('http:/​/​mozilla.org'))12 self.assertFalse(is_url('/​usr/​bin/​mozilla.org'))13 self.assertTrue(is_url('file:/​/​/​usr/​bin/​mozilla.org'))14 self.assertFalse(is_url('c:\foo\bar'))15if __name__ == '__main__':...
Check out the latest blogs from LambdaTest on this topic:
With the rising demand for new services and technologies in the IT, manufacturing, healthcare, and financial sector, QA/ DevOps engineering has become the most important part of software companies. Below is a list of some characteristics to look for when interviewing a potential candidate.
Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.
How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
When most firms employed a waterfall development model, it was widely joked about in the industry that Google kept its products in beta forever. Google has been a pioneer in making the case for in-production testing. Traditionally, before a build could go live, a tester was responsible for testing all scenarios, both defined and extempore, in a testing environment. However, this concept is evolving on multiple fronts today. For example, the tester is no longer testing alone. Developers, designers, build engineers, other stakeholders, and end users, both inside and outside the product team, are testing the product and providing feedback.
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!!