Best Python code snippet using lisa_python
test_global_settings.py
Source:test_global_settings.py
...13 if hasattr(conf.settings, 'DDF_FILL_NULLABLE_FIELDS'): del conf.settings.DDF_FILL_NULLABLE_FIELDS14 if hasattr(conf.settings, 'DDF_IGNORE_FIELDS'): del conf.settings.DDF_IGNORE_FIELDS15 if hasattr(conf.settings, 'DDF_NUMBER_OF_LAPS'): del conf.settings.DDF_NUMBER_OF_LAPS16 if hasattr(conf.settings, 'DDF_VALIDATE_MODELS'): del conf.settings.DDF_VALIDATE_MODELS17 reload_module(conf)18class CustomDataFixture(object): pass19class DDF_DEFAULT_DATA_FIXTURE_TestCase(AbstractGlobalSettingsTestCase):20 def test_not_configured_must_load_default_value(self):21 reload_module(global_settings)22 assert SequentialDataFixture == type(global_settings.DDF_DEFAULT_DATA_FIXTURE)23 def test_may_be_an_internal_data_fixture_nick_name(self):24 conf.settings.DDF_DEFAULT_DATA_FIXTURE = 'sequential'25 reload_module(global_settings)26 assert SequentialDataFixture == type(global_settings.DDF_DEFAULT_DATA_FIXTURE)27 conf.settings.DDF_DEFAULT_DATA_FIXTURE = 'random'28 reload_module(global_settings)29 assert RandomDataFixture == type(global_settings.DDF_DEFAULT_DATA_FIXTURE)30 conf.settings.DDF_DEFAULT_DATA_FIXTURE = 'static_sequential'31 reload_module(global_settings)32 assert StaticSequentialDataFixture == type(global_settings.DDF_DEFAULT_DATA_FIXTURE)33 def test_may_be_a_path_to_a_custom_data_fixture(self):34 conf.settings.DDF_DEFAULT_DATA_FIXTURE = 'django_dynamic_fixture.tests.test_global_settings.CustomDataFixture'35 reload_module(global_settings)36 assert CustomDataFixture == type(global_settings.DDF_DEFAULT_DATA_FIXTURE)37 def test_if_path_can_not_be_found_it_will_raise_an_exception(self):38 conf.settings.DDF_DEFAULT_DATA_FIXTURE = 'unknown_path.CustomDataFixture'39 with pytest.raises(Exception):40 reload_module(global_settings)41class DDF_FILL_NULLABLE_FIELDS_TestCase(AbstractGlobalSettingsTestCase):42 def test_not_configured_must_load_default_value(self):43 reload_module(global_settings)44 assert global_settings.DDF_FILL_NULLABLE_FIELDS == False45 def test_must_be_a_boolean(self):46 conf.settings.DDF_FILL_NULLABLE_FIELDS = True47 reload_module(global_settings)48 assert global_settings.DDF_FILL_NULLABLE_FIELDS49 def test_must_raise_an_exception_if_it_is_not_a_boolean(self):50 conf.settings.DDF_FILL_NULLABLE_FIELDS = 'x'51 with pytest.raises(Exception):52 reload_module(global_settings)53class DDF_IGNORE_FIELDS_TestCase(AbstractGlobalSettingsTestCase):54 def test_not_configured_must_load_default_value(self):55 reload_module(global_settings)56 assert global_settings.DDF_IGNORE_FIELDS == []57 def test_must_be_a_list_of_strings(self):58 conf.settings.DDF_IGNORE_FIELDS = ['x']59 reload_module(global_settings)60 assert global_settings.DDF_IGNORE_FIELDS == ['x']61 def test_must_raise_an_exception_if_it_is_not_an_list_of_strings(self):62 conf.settings.DDF_IGNORE_FIELDS = None63 with pytest.raises(Exception):64 reload_module(global_settings)65class DDF_FK_MIN_DEPTH_TestCase(AbstractGlobalSettingsTestCase):66 def test_not_configured_must_load_default_value(self):67 reload_module(global_settings)68 assert global_settings.DDF_FK_MIN_DEPTH == 069 def test_must_be_an_integer(self):70 conf.settings.DDF_FK_MIN_DEPTH = 271 reload_module(global_settings)72 assert global_settings.DDF_FK_MIN_DEPTH == 273 def test_must_raise_an_exception_if_it_is_not_an_integer(self):74 conf.settings.DDF_FK_MIN_DEPTH = None75 with pytest.raises(Exception):76 reload_module(global_settings)77class DDF_VALIDATE_MODELS_TestCase(AbstractGlobalSettingsTestCase):78 def test_not_configured_must_load_default_value(self):79 reload_module(global_settings)80 assert global_settings.DDF_VALIDATE_MODELS == False81 def test_must_be_a_boolean(self):82 conf.settings.DDF_VALIDATE_MODELS = False83 reload_module(global_settings)84 assert global_settings.DDF_VALIDATE_MODELS == False85 def test_must_raise_an_exception_if_it_is_not_a_boolean(self):86 conf.settings.DDF_VALIDATE_MODELS = 'x'87 with pytest.raises(Exception):...
test_ragged.py
Source:test_ragged.py
...17##18# v00 has a ragged edge.19# v01 makes that a right. angle20from stompy.grid import triangulate_hole, rebay21six.moves.reload_module(rebay)22six.moves.reload_module(triangulate_hole)23six.moves.reload_module(quads)24if 0: 25 gen_src=unstructured_grid.UnstructuredGrid.read_pickle('grid_lagoon-v00.pkl')26 qg=quads.QuadGen(gen_src,cell=0,final='anisotropic',execute=True,nom_res=5,27 gradient_scale=1.0)28 qg.plot_result()29gen_src=unstructured_grid.UnstructuredGrid.read_pickle('grid_lagoon-v02.pkl')30## 31# Testing a grid with a 360-degree vertex, and much more complicated32# patter33six.moves.reload_module(unstructured_grid)34six.moves.reload_module(exact_delaunay)35six.moves.reload_module(rebay)36six.moves.reload_module(triangulate_hole)37six.moves.reload_module(quads)38qg=quads.QuadGen(gen_src,cell=0,final='anisotropic',execute=False,nom_res=5)39qg.add_internal_edge([23,36])40qg.add_internal_edge([20,32])41qg.execute()42# All the code below is now in quad_laplacian.py43##44g=qg.g_final45plt.figure(4).clf()46fig,ax=plt.subplots(num=4)47g.plot_edges(color='k',lw=0.5)48g.plot_cells(color='0.8',lw=0,zorder=-2)49#g.plot_nodes(sizes=40,alpha=0.2,color='r')50ax.axis('off')51ax.set_position([0,0,1,1])...
gen_quads.py
Source:gen_quads.py
...14import stompy.plot.cmap as scmap15##16from stompy.grid import triangulate_hole, orthogonalize,shadow_cdt, front17from stompy.spatial import wkb2shp, constrained_delaunay18six.moves.reload_module(unstructured_grid)19six.moves.reload_module(exact_delaunay)20six.moves.reload_module(constrained_delaunay)21six.moves.reload_module(shadow_cdt)22six.moves.reload_module(front)23six.moves.reload_module(triangulate_hole)24six.moves.reload_module(orthogonalize)25six.moves.reload_module(quads)26ver='v20'27gen_src=unstructured_grid.UnstructuredGrid.read_pickle(f'grid_lagoon-{ver}.pkl')28##29if 1:30 plt.figure(10).clf()31 gen_src.plot_cells(labeler='id',centroid=True)32 plt.axis('tight')33 plt.axis('equal')34## 35sqg=quads.SimpleQuadGen(gen_src,list(gen_src.valid_cell_iter()),36 nom_res=2.5,execute=False)37sqg.execute()38## 39g=sqg.g_final...
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!!