Best Python code snippet using grail_python
conftest.py
Source:conftest.py
...76 marker instead.77 This functionality should be invoked as a pytest marker, e.g.:78 ```79 @pytest.mark.requires_url("http://codebender.cc")80 def test_some_feature():81 ...82 ```83 """84 if request.node.get_marker('requires_url'):85 required_url = request.node.get_marker('requires_url').args[0]86 if required_url.rstrip('/') != testing_url.rstrip('/'):87 pytest.skip('skipped test that requires --url=%s' % required_url)88@pytest.fixture(autouse=True)89def does_not_require_extension(request, webdriver):90 """Mark that a test doesn't require the codebender extension.91 This marker is used so that we skip tests when running under chrome since92 we have an unexpected behavior when the extension is not installed.93 This functionality should be invoked as a pytest marker, e.g.:94 ```95 @pytest.mark.does_not_require_extension96 def test_some_feature():97 ...98 ```99 """100 if request.node.get_marker('does_not_require_extension'):101 if webdriver.desired_capabilities["browserName"] == "chrome":...
slow_test_report_test.py
Source:slow_test_report_test.py
1import StringIO2import unittest3from slow_test_report import SlowTestReport4class SlowTestReportTest(unittest.TestCase):5 def setUp(self):6 self.report_file = StringIO.StringIO("""\7<testsuite8 errors="0"9 failures="0"10 name="Django Project Tests"11 skips="0"12 tests="3"13 time="10.042">14 <properties/>15 <testcase16 classname="app1.tests.SomeTest"17 name="test_some_feature"18 time="6.04192" />19 <testcase20 classname="app1.tests.SomeOtherTest"21 name="test_other_feature"22 time="1" />23 <testcase24 classname="app2.tests.AnotherTest"25 name="test_stuff"26 time="3" />27</testsuite>28""")29 self.other_report_file = StringIO.StringIO("""\30<testsuite31 errors="0"32 failures="0"33 name="Django Project Other Tests"34 skips="0"35 tests="1"36 time="5">37 <testcase38 classname="app3.tests.WholeDifferentTest"39 name="test_crazy_feature"40 time="5" />41</testsuite>42""")43 def test_summary(self):44 expected_description = '2 out of 3 tests took 9s out of 10s'45 report = SlowTestReport().load([self.report_file], 2)46 self.assertSequenceEqual(expected_description, report.description)47 def test_slowest(self):48 expected_description = '6s for app1.SomeTest.test_some_feature'49 report = SlowTestReport().load([self.report_file], 2)50 test = report.tests[0]51 self.assertSequenceEqual(expected_description, test.description)52 def test_multiple_files(self):53 expected_description = '2 out of 4 tests took 11s out of 15s'54 report = SlowTestReport().load([self.report_file,55 self.other_report_file],56 2)...
test_example.py
Source:test_example.py
...5@step(log_input=False)6def decrease(v):7 return v-18class TestClass(object):9 def test_some_feature(self):10 result = self.do_some_calculation(2, second_param=3)11 self.verify_result(result)12 increase(result)13 decrease(result)14 @step(step_group=True)15 def do_some_calculation(self, first_param, second_param):16 first_param = increase(first_param)17 second_param = increase(second_param)18 return first_param + second_param19 @step(log_input=False)20 def verify_result(self, actual_data):...
8_log_input_output.py
Source:8_log_input_output.py
1from grail import BaseTest, step2class MyDisableLogOutputTest(BaseTest):3 def test_some_feature(self):4 self.log_output()5 self.do_not_log_output()6 @step7 def log_output(self):8 return 'Important output'9 @step(log_output=False)10 def do_not_log_output(self):11 return 'Some invisible in logs data'12class MyDisableLogInputTest(BaseTest):13 def test_some_feature(self):14 self.log_input('input data')15 self.do_not_log_input('input data')16 @step17 def log_input(self, input_data):18 pass19 @step(log_input=False)20 def do_not_log_input(self, input_data):...
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!!