How to use test_example_1 method in SeleniumBase

Best Python code snippet using SeleniumBase

InowasModflowReadAdapter_test.py

Source:InowasModflowReadAdapter_test.py Github

copy

Full Screen

1import unittest2from ...Read import InowasModflowReadAdapter3class InowasModflowReadAdapterTest(unittest.TestCase):4 def it_can_be_instantiated_test(self):5 instance = InowasModflowReadAdapter()6 self.assertIsInstance(instance, InowasModflowReadAdapter)7 def it_throws_exception_if_path_is_wrong_test(self):8 with self.assertRaises(FileNotFoundError) as context:9 InowasModflowReadAdapter.load('abc')10 self.assertEqual('Path not found: abc', str(context.exception))11 def it_throws_exception_if_path_does_not_contain_name_file_test(self):12 with self.assertRaises(FileNotFoundError) as context:13 InowasModflowReadAdapter.load('./FlopyAdapter/test/Read/data/emptyFolder')14 self.assertEqual('Modflow name file with ending .nam or .mfn not found', str(context.exception))15 def it_loads_the_model_correctly_test(self):16 instance = InowasModflowReadAdapter.load('./FlopyAdapter/test/Read/data/test_example_1')17 self.assertIsInstance(instance, InowasModflowReadAdapter)18 def it_loads_the_model_correctly_with_crs_test(self):19 instance = InowasModflowReadAdapter.load_with_crs(20 './FlopyAdapter/test/Read/data/test_example_1',21 279972.0566, 9099724.9436, 31985, -15.522 )23 self.assertIsInstance(instance, InowasModflowReadAdapter)24 from flopy.discretization import StructuredGrid25 mg = instance.modelgrid26 self.assertIsInstance(mg, StructuredGrid)27 self.assertEqual(mg.epsg, '32725')28 self.assertEqual(round(mg.xoffset), 279972)29 self.assertEqual(round(mg.yoffset), 9099725)30 self.assertEqual(mg.angrot, -15.5)31 def it_converts_wgs84_to_utm_correctly_test(self):32 lat = 50.96631933 long = 13.92327334 easting, northing, zone_number, zone_letter = InowasModflowReadAdapter.wgs82ToUtm(long, lat)35 self.assertEqual(round(easting), 424393)36 self.assertEqual(round(northing), 5646631)37 self.assertEqual(zone_number, 33)38 self.assertEqual(zone_letter, 'U')39 def it_converts_utm_to_wgs84_correctly_test(self):40 easting, northing, zone_number, zone_letter = 424393, 5646631, 33, 'U'41 long, lat = InowasModflowReadAdapter.utmToWgs82XY(easting, northing, zone_number, zone_letter)42 self.assertEqual(round(long, 5), 13.92328)43 self.assertEqual(round(lat, 5), 50.96632)44 def it_returns_a_model_geometry_correctly_test(self):45 instance = InowasModflowReadAdapter.load_with_crs(46 './FlopyAdapter/test/Read/data/test_example_1',47 279972.0566, 9099724.9436, 31985, -15.548 )49 geometry = instance.model_geometry(4326, 0)50 self.assertEqual(geometry["type"], 'Polygon')51 #self.assertEqual(len(geometry["coordinates"][0]), 520)52 #self.assertEqual(geometry["coordinates"][0][0], [-34.874831, -8.073991])53 def it_returns_model_gid_size_test(self):54 instance = InowasModflowReadAdapter.load('./FlopyAdapter/test/Read/data/test_example_1')55 self.assertIsInstance(instance, InowasModflowReadAdapter)56 grid_size = instance.model_grid_size()57 self.assertEqual(grid_size, {58 'n_x': 227,59 'n_y': 221,60 })61 def it_returns_model_stressperiods_test(self):62 instance = InowasModflowReadAdapter.load('./FlopyAdapter/test/Read/data/test_example_1')63 self.assertIsInstance(instance, InowasModflowReadAdapter)64 stress_periods = instance.model_stress_periods()65 expected = {66 'start_date_time': '1970-01-01',67 'end_date_time': '1970-02-06',68 'time_unit': 4,69 'stressperiods': [70 {71 'start_date_time': '1970-01-01',72 'nstp': 1,73 'tsmult': 1.0,74 'steady': True,75 },76 {77 'start_date_time': '1970-01-02',78 'nstp': 5,79 'tsmult': 1.0,80 'steady': False,81 },82 {83 'start_date_time': '1970-01-12',84 'nstp': 10,85 'tsmult': 1.5,86 'steady': False,87 }88 ]89 }90 self.assertEqual(stress_periods, expected)91 def it_returns_model_length_unit_test(self):92 instance = InowasModflowReadAdapter.load('./FlopyAdapter/test/Read/data/test_example_1')93 self.assertIsInstance(instance, InowasModflowReadAdapter)94 length_unit = instance.model_length_unit()95 self.assertEqual(length_unit, 2)96 def it_returns_model_time_unit_test(self):97 instance = InowasModflowReadAdapter.load('./FlopyAdapter/test/Read/data/test_example_1')98 self.assertIsInstance(instance, InowasModflowReadAdapter)99 time_unit = instance.model_time_unit()100 self.assertEqual(time_unit, 4)101 def it_returns_wel_boundaries_of_example_1_test(self):102 instance = InowasModflowReadAdapter.load_with_crs(103 './FlopyAdapter/test/Read/data/test_example_1',104 279972.0566, 9099724.9436, 31985, -15.5105 )106 self.assertIsInstance(instance, InowasModflowReadAdapter)107 wel_boundaries = instance.wel_boundaries(target_epsg=4326)108 self.assertEqual(len(wel_boundaries), 93)109 print(wel_boundaries[0])110 self.assertEqual(wel_boundaries[0],111 {112 'type': 'wel',113 'name': 'Well 1',114 'geometry': {"coordinates": [-34.879083, -8.084035], "type": "Point"},115 'layers': [0],116 'sp_values': [-2039.0, -2039.0, -2039.0], 'cells': [[217, 31]]117 }118 )119 def it_returns_wel_boundaries_of_example_2_test(self):120 instance = InowasModflowReadAdapter.load_with_crs(121 './FlopyAdapter/test/Read/data/test_example_2',122 0, 0, 4326, 0123 )124 self.assertIsInstance(instance, InowasModflowReadAdapter)125 wel_boundaries = instance.wel_boundaries(target_epsg=4326)126 self.assertEqual(len(wel_boundaries), 6)127 self.assertEqual(wel_boundaries, [128 {129 'type': 'wel',130 'name': 'Well 1',131 'geometry': {"coordinates": [0.013461, 0.040657], "type": "Point"},132 'layers': [0],133 'sp_values': [0, -5000.0, -5000.0],134 'cells': [[1, 1]]135 }, {136 'type': 'wel',137 'name': 'Well 2',138 'geometry': {"coordinates": [0.022435, 0.040658], "type": "Point"},139 'layers': [0],140 'sp_values': [0, -5000.0, -5000.0],141 'cells': [[2, 1]]142 },143 {144 'type': 'wel',145 'name': 'Well 3',146 'geometry': {"coordinates": [0.058334, 0.040659], "type": "Point"},147 'layers': [0],148 'sp_values': [0, -10000.0, -10000.0],149 'cells': [[6, 1]]150 },151 {152 'type': 'wel',153 'name': 'Well 4',154 'geometry': {"coordinates": [0.085259, 0.04066], "type": "Point"},155 'layers': [0],156 'sp_values': [0, -5000.0, -5000.0],157 'cells': [[9, 1]]158 },159 {160 'type': 'wel',161 'name': 'Well 5',162 'geometry': {"coordinates": [0.013461, 0.022587], "type": "Point"},163 'layers': [0],164 'sp_values': [0, -5000.0, -5000.0],165 'cells': [[1, 3]]166 },167 {168 'type': 'wel',169 'name': 'Well 6',170 'geometry': {"coordinates": [0.040385, 0.013553], "type": "Point"},171 'layers': [0],172 'sp_values': [0, -5000.0, -5000.0],173 'cells': [[4, 4]]174 }])175if __name__ == "__main__":...

Full Screen

Full Screen

test_pytest_failed_to_verify.py

Source:test_pytest_failed_to_verify.py Github

copy

Full Screen

...9 import pytest10 @pytest.fixture(scope='function', autouse=True)11 def function_setup_teardown():12 {0}13 def test_example_1():14 assert True15 """.format(temporary_failure())16 )17 result = testdir.runpytest(*pytest_command.split())18 assert '1 setup rerun' in result.stdout.str()19 assert '1 failed to verify' in result.stdout.str()20 assert 'FAILED TO VERIFY' in result.stdout.str()21 assert 'Exception: Failure' in result.stdout.str()22 assert result.ret == 123@pytest.mark.parametrize("pytest_command", ['--rerun-setup 2', '--rerun-setup 2 -x'])24def test_fail_to_verify_if_setup_fails_multiple_times(pytest_command, testdir):25 testdir.makepyfile(26 """27 import pytest28 @pytest.fixture(scope='function', autouse=True)29 def function_setup_teardown():30 {0}31 def test_example_1():32 assert True33 """.format(temporary_failure())34 )35 result = testdir.runpytest(*pytest_command.split())36 assert '2 setup rerun' in result.stdout.str()37 assert '1 failed to verify' in result.stdout.str()38 assert 'FAILED TO VERIFY' in result.stdout.str()39 assert 'Exception: Failure' in result.stdout.str()40 assert result.ret == 141@pytest.mark.parametrize("pytest_command", ['--rerun-setup 1', '--rerun-setup 1 -x'])42def test_fail_setup_and_pass(pytest_command, testdir):43 testdir.makepyfile(44 """45 import pytest46 COUNT = 047 @pytest.fixture(scope='function', autouse=True)48 def function_setup_teardown():49 global COUNT50 if COUNT == 0:51 COUNT += 152 assert False53 else:54 assert True55 def test_example_1():56 assert True57 """58 )59 result = testdir.runpytest(*pytest_command.split())60 assert 'failed to verify' not in result.stdout.str()61 assert '1 setup rerun' in result.stdout.str()62 assert '1 passed' in result.stdout.str()63 assert result.ret == 064@pytest.mark.parametrize("pytest_command", ['--rerun-setup 1', '--rerun-setup 1 -x'])65def test_passed_in_output_if_setup_and_test_successfull(pytest_command, testdir):66 testdir.makepyfile(67 """68 import pytest69 @pytest.fixture(scope='function', autouse=True)70 def function_setup_teardown():71 pass72 def test_example_1():73 assert True74 """75 )76 result = testdir.runpytest(*pytest_command.split())77 assert 'FAILED TO VERIFY' not in result.stdout.str()78 assert '1 failed to verify' not in result.stdout.str()79 assert 'PASSED' not in result.stdout.str()80 assert '1 passed' in result.stdout.str()81 assert result.ret == 082@pytest.mark.parametrize("pytest_command", ['--rerun-setup 1', '--rerun-setup 1 -x'])83def test_failed_in_output_on_error_in_test_logic(pytest_command, testdir):84 testdir.makepyfile(85 """86 import pytest87 @pytest.fixture(scope='function', autouse=True)88 def function_setup_teardown():89 pass90 def test_example_1():91 assert False92 """93 )94 result = testdir.runpytest(*pytest_command.split())95 assert 'setup rerun' not in result.stdout.str()96 assert 'FAILED' not in result.stdout.str()97 assert '1 failed' in result.stdout.str()98 assert 'falied to verify' not in result.stdout.str()99 assert 'setup rerun' not in result.stdout.str()100 assert 'passed' not in result.stdout.str()101 assert result.ret == 1102@pytest.mark.parametrize("pytest_command", ['--rerun-setup 1', '--rerun-setup 1 -x'])103def test_skipped(pytest_command, testdir):104 testdir.makepyfile(105 """106 import pytest107 @pytest.fixture(scope='function', autouse=True)108 def function_setup_teardown():109 assert True110 @pytest.mark.skip(reason='Reason why skipped')111 def test_example_1():112 assert True113 """114 )115 result = testdir.runpytest(*pytest_command.split())116 assert 'FAILED TO VERIFY' not in result.stdout.str()117 assert 'failed to verify' not in result.stdout.str()118 assert 'FAILED' not in result.stdout.str()119 assert 'setup rerun' not in result.stdout.str()120 assert '1 skipped' in result.stdout.str()121 assert result.ret == 0122@pytest.mark.parametrize("pytest_command", ['--rerun-setup 1', '--rerun-setup 1 -x'])123def test_skipped_and_setup_fail(pytest_command, testdir):124 testdir.makepyfile(125 """126 import pytest127 @pytest.fixture(scope='function', autouse=True)128 def function_setup_teardown():129 assert False130 @pytest.mark.skip(reason='Reason why skipped')131 def test_example_1():132 assert True133 """134 )135 result = testdir.runpytest(*pytest_command.split())136 assert 'FAILED TO VERIFY' not in result.stdout.str()137 assert 'failed to verify' not in result.stdout.str()138 assert 'FAILED' not in result.stdout.str()139 assert 'setup rerun' not in result.stdout.str()140 assert '1 skipped' in result.stdout.str()141 assert result.ret == 0142@pytest.mark.parametrize("pytest_command", ['--rerun-setup 1', '--rerun-setup 1 -x'])143def test_xfail(pytest_command, testdir):144 testdir.makepyfile(145 """146 import pytest147 @pytest.fixture(scope='function', autouse=True)148 def function_setup_teardown():149 assert True150 @pytest.mark.xfail(reason='Reason why skipped')151 def test_example_1():152 assert True153 """154 )155 result = testdir.runpytest(*pytest_command.split())156 assert 'FAILED TO VERIFY' not in result.stdout.str()157 assert 'failed to verify' not in result.stdout.str()158 assert 'FAILED' not in result.stdout.str()159 assert 'setup rerun' not in result.stdout.str()160 assert '1 xpassed' in result.stdout.str()161 assert result.ret == 0162@pytest.mark.parametrize("pytest_command", ['--rerun-setup 1', '--rerun-setup 1 -x'])163def test_xfail_and_setup_failure(pytest_command, testdir):164 testdir.makepyfile(165 """166 import pytest167 @pytest.fixture(scope='function', autouse=True)168 def function_setup_teardown():169 {0}170 @pytest.mark.xfail(reason='Reason why skipped')171 def test_example_1():172 assert True173 """.format(temporary_failure())174 )175 result = testdir.runpytest(*pytest_command.split())176 assert 'FAILED TO VERIFY' in result.stdout.str()177 assert 'failed to verify' in result.stdout.str()178 assert 'setup rerun' in result.stdout.str()179 assert '1 failed to verify' in result.stdout.str()180 assert 'Exception: Failure' in result.stdout.str()...

Full Screen

Full Screen

result.py

Source:result.py Github

copy

Full Screen

1import unittest2class TestExample(unittest.TestCase):3 def test_example_1(self):4 self.assertTrue(True)5 def test_example_2(self):6 self.assertTrue(False, 'example of failed test')7 @unittest.skip('example of skipped test')8 def test_example_3(self):9 self.assertTrue(True)10def suite():11 suite = unittest.TestSuite()12 suite.addTest(TestExample('test_example_1'))13 suite.addTest(TestExample('test_example_2'))14 suite.addTest(TestExample('test_example_3'))15 return suite16if __name__ == '__main__':17 result = unittest.TextTestRunner(verbosity=2).run(suite())

Full Screen

Full Screen

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 SeleniumBase 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