How to use is_supported method in lisa

Best Python code snippet using lisa_python

GLCompatibility.py

Source:GLCompatibility.py Github

copy

Full Screen

1def is_supported(feature_name):2 return feature_name in is_supported.exts3def support_all(feature_names):4 for feature_name in feature_names:5 if not is_supported(feature_name):6 return False7 return True8def support_one(feature_names):9 for feature_name in feature_names:10 if is_supported(feature_name):11 return True12 return False13ogl_ver_db = ['1.1', '1.2', '1.3', '1.4', '1.5', '2.0', '2.1', '3.0', '3.1', '3.2', '3.3', '4.0', '4.1', '4.2', '4.3', '4.4', '4.5', '4.6']14glsl_ver_db = ['0.0', '1.1', '1.2', '1.3', '1.4', '1.5', '3.3', '4.0', '4.1', '4.2', '4.3', '4.4', '4.5', '4.6']15features_db = {16 '1.1' : {17 'Vertex Array' : lambda : is_supported('GL_EXT_vertex_array'),18 'Polygon Offset' : lambda : is_supported('GL_EXT_polygon_offset'),19 'Logical Operation' : lambda : is_supported('GL_EXT_blend_logic_op'),20 'Texture Image Formats' : lambda : is_supported('GL_EXT_texture'),21 'Texture Replace Environment' : lambda : is_supported('GL_EXT_texture'),22 'Texture Proxies' : lambda : is_supported('GL_EXT_texture'),23 'Copy Texture and Subtexture' : lambda : support_all(['GL_EXT_copy_texture', 'GL_EXT_subtexture']),24 'Texture Objects' : lambda : is_supported('GL_EXT_texture_object')25 },26 '1.2' : {27 'Three-Dimensional Texturing' : lambda : is_supported('GL_EXT_texture3D'),28 'BGRA Pixel Formats' : lambda : is_supported('GL_EXT_bgra'),29 'Packed Pixel Formats' : lambda : is_supported('GL_EXT_packed_pixels'),30 'Normal Rescaling' : lambda : is_supported('GL_EXT_rescale_normal'),31 'Separate Specular Color' : lambda : is_supported('GL_EXT_separate_specular_color'),32 'Texture Coordinate Edge Clamping' : lambda : is_supported('GL_SGIS_texture_edge_clamp'),33 'Texture Level of Detail Control' : lambda : is_supported('GL_SGIS_texture_lod'),34 'Vertex Array Draw Element Range' : lambda : is_supported('GL_EXT_draw_range_elements'),35 'Imaging Subset' : lambda : is_supported('GL_ARB_imaging'),36 'Color Tables' : lambda : support_one(['GL_SGI_color_table', 'GL_EXT_paletted_texture']) and is_supported('GL_EXT_color_subtable'),37 'Convolution' : lambda : support_all(['GL_EXT_convolution', 'GL_HP_convolution_border_modes']),38 'Color Matrix' : lambda : is_supported('GL_SGI_color_matrix'),39 'Pixel Pipeline Statistics' : lambda : is_supported('GL_EXT_histogram'),40 'Constant Blend Color' : lambda : is_supported('GL_EXT_blend_color'),41 'New Blending Equations' : lambda : support_all(['GL_EXT_blend_minmax', 'GL_EXT_blend_subtract'])42 },43 '1.3' : {44 'Compressed Textures' : lambda : is_supported('GL_ARB_texture_compression'),45 'Cube Map Textures' : lambda : is_supported('GL_ARB_texture_cube_map'),46 'Multisample' : lambda : is_supported('GL_ARB_multisample'),47 'Multitexture' : lambda : is_supported('GL_ARB_multitexture'),48 'Texture Add Environment Mode' : lambda : support_one(['GL_ARB_texture_env_add', 'GL_EXT_texture_env_add']),49 'Texture Combine Environment Mode' : lambda : support_one(['GL_ARB_texture_env_combine', 'GL_EXT_texture_env_combine']),50 'Texture Dot3 Environment Mode' : lambda : support_one(['GL_ARB_texture_env_dot3', 'GL_EXT_texture_env_dot3']),51 'Texture Border Clamp' : lambda : support_one(['GL_ARB_texture_border_clamp', 'GL_SGIS_texture_border_clamp']),52 'Transpose Matrix' : lambda : is_supported('GL_ARB_transpose_matrix')53 },54 '1.4' : {55 'Automatic Mipmap Generation' : lambda : is_supported('GL_SGIS_generate_mipmap'),56 'Blend Squaring' : lambda : is_supported('GL_NV_blend_square'),57 'Depth Textures' : lambda : support_one(['GL_ARB_depth_texture', 'GL_SGIX_depth_texture']),58 'Shadows' : lambda : support_one(['GL_ARB_shadow', 'GL_SGIX_shadow']),59 'Fog Coordinate' : lambda : is_supported('GL_EXT_fog_coord'),60 'Multiple Draw Arrays' : lambda : support_one(['GL_EXT_multi_draw_arrays', 'GL_SUN_multi_draw_arrays']),61 'Point Parameters' : lambda : support_one(['GL_ARB_point_parameters', 'GL_EXT_point_parameters']),62 'Secondary Color' : lambda : is_supported('GL_EXT_secondary_color'),63 'Separate Blend Functions' : lambda : is_supported('GL_EXT_blend_func_separate'),64 'Stencil Wrap' : lambda : is_supported('GL_EXT_stencil_wrap'),65 'Texture Crossbar Environment Mode' : lambda : support_one(['GL_ARB_texture_env_crossbar', 'GL_NV_texture_env_combine4']),66 'Texture LOD Bias' : lambda : is_supported('GL_EXT_texture_lod_bias'),67 'Texture Mirrored Repeat' : lambda : is_supported('GL_ARB_texture_mirrored_repeat'),68 'Window Raster Position' : lambda : support_one(['GL_ARB_window_pos', 'GL_MESA_window_pos'])69 },70 '1.5' : {71 'Buffer Objects' : lambda : is_supported('GL_ARB_vertex_buffer_object'),72 'Occlusion Queries' : lambda : support_one(['GL_ARB_occlusion_query', 'GL_NV_occlusion_query', 'GL_HP_occlusion_test']),73 'Shadow Functions' : lambda : is_supported('GL_EXT_shadow_funcs')74 },75 '2.0' : {76 'Shader Objects' : lambda : is_supported('GL_ARB_shader_objects'),77 'Shader Programs' : lambda : support_all(['GL_ARB_vertex_shader', 'GL_ARB_fragment_shader']),78 'OpenGL Shading Language' : lambda : is_supported('GL_ARB_shading_language_100'),79 'Multiple Render Targets' : lambda : support_one(['GL_ARB_draw_buffers', 'GL_ATI_draw_buffers']),80 'Non-Power-Of-Two Textures' : lambda : is_supported('GL_ARB_texture_non_power_of_two'),81 'Point Sprites' : lambda : support_one(['GL_ARB_point_sprite', 'GL_NV_point_sprite']),82 'Separate Stencil' : lambda : support_one(['GL_ATI_separate_stencil', 'GL_EXT_stencil_two_side']),83 'Separated Blend Equation' : lambda : is_supported('GL_EXT_blend_equation_separate')84 },85 '2.1' : {86 'OpenGL Shading Language 1.20' : lambda : support_one(['GLSL_1_2', 'GL_ATI_shader_texture_lod']),87 'Pixel buffer object' : lambda : support_one(['GL_ARB_pixel_buffer_object', 'GL_EXT_pixel_buffer_object']),88 'sRGB texture' : lambda : support_one(['GL_EXT_texture_sRGB']),89 },90 91 '3.0' : {92 'OpenGL Shading Language 1.30' : lambda : support_one(['GLSL_1_3', 'GL_EXT_gpu_shader4']),93 'Conditional rendering' : lambda : is_supported('GL_NV_conditional_render'),94 'Floating-point color buffer' : lambda : is_supported('GL_ARB_color_buffer_float'),95 'Floating-point depth buffer' : lambda : support_one(['GL_ARB_depth_buffer_float', 'GL_NV_depth_buffer_float']),96 'Floating-point texture' : lambda : support_one(['GL_ARB_texture_float', 'GL_ATI_texture_float', 'GL_NV_float_buffer']),97 'Packed float' : lambda : is_supported('GL_EXT_packed_float'),98 'Shared exponent' : lambda : is_supported('GL_EXT_texture_shared_exponent'),99 'Frame buffer object' : lambda : support_one(['GL_ARB_framebuffer_object', 'GL_EXT_framebuffer_object']),100 'Multisample stretch blit' : lambda : support_all(['GL_EXT_framebuffer_multisample', 'GL_EXT_framebuffer_blit']),101 'Integer texture' : lambda : is_supported('GL_EXT_texture_integer'),102 'Texture array' : lambda : is_supported('GL_EXT_texture_array'),103 'Packed depth stencil format' : lambda : is_supported('GL_EXT_packed_depth_stencil'),104 'Per-color-attachment blend enables and color writemasks' : lambda : is_supported('GL_EXT_draw_buffers2'),105 'Transform feedback' : lambda : support_one(['GL_EXT_transform_feedback', 'GL_NV_transform_feedback']),106 'sRGB-encoded framebuffer' : lambda : support_one(['GL_ARB_framebuffer_sRGB', 'GL_EXT_framebuffer_sRGB']),107 'Half-float data type in vertex' : lambda : is_supported('GL_ARB_half_float_vertex'),108 'Map buffer range' : lambda : is_supported('GL_ARB_map_buffer_range'),109 'R and RG texture compression' : lambda : support_one(['GL_ARB_texture_compression_rgtc', 'GL_EXT_texture_compression_rgtc']),110 'R and RG texture' : lambda : is_supported('GL_ARB_texture_rg'),111 'Vertex array object' : lambda : support_one(['GL_ARB_vertex_array_object', 'GL_APPLE_vertex_array_object']),112 },113 114 '3.1' : {115 'OpenGL Shading Language 1.40' : lambda : is_supported('GLSL_1_4'),116 'Instanced rendering' : lambda : is_supported('GL_ARB_draw_instanced'),117 'Data copying between buffer objects' : lambda : support_one(['GL_ARB_copy_buffer', 'GL_EXT_copy_buffer']),118 'Primitive restart' : lambda : is_supported('GL_NV_primitive_restart'),119 'Texture buffer objects' : lambda : is_supported('GL_ARB_texture_buffer_object'),120 'Rectangular textures' : lambda : support_one(['GL_ARB_texture_rectangle', 'GL_EXT_texture_rectangle', 'GL_NV_texture_rectangle']),121 'Uniform buffer objects' : lambda : support_one(['GL_ARB_uniform_buffer_object', 'GL_EXT_bindable_uniform']),122 'Signed normalized texture component formats' : lambda : support_one(['GL_EXT_texture_snorm', 'GL_NV_texture_shader']),123 },124 125 '3.2' : {126 'OpenGL Shading Language 1.50' : lambda : is_supported('GLSL_1_5'),127 'Compatibility profiles' : lambda : is_supported('GL_ARB_compatibility'),128 'BGRA vertex component ordering' : lambda : support_one(['GL_ARB_vertex_array_bgra', 'GL_EXT_vertex_array_bgra']),129 'Modification of the base vertex index' : lambda : is_supported('GL_ARB_draw_elements_base_vertex'),130 'Shader fragment coordinate convention control' : lambda : is_supported('GL_ARB_fragment_coord_conventions'),131 'Provoking vertex control' : lambda : support_one(['GL_ARB_provoking_vertex', 'GL_EXT_provoking_vertex']),132 'Seamless cube map filtering' : lambda : is_supported('GL_ARB_seamless_cube_map'),133 'Multisampled textures and texture samplers for specific sample locations' : lambda : is_supported('GL_ARB_texture_multisample'),134 'Fragment depth clamping' : lambda : support_one(['GL_ARB_depth_clamp', 'GL_NV_depth_clamp']),135 'Geometry shaders' : lambda : support_one(['GL_ARB_geometry_shader4', 'GL_EXT_geometry_shader4', 'GL_NV_geometry_shader4', 'GL_NV_geometry_program4']),136 'Fence sync objects' : lambda : support_one(['GL_ARB_sync', 'GL_NV_fence']),137 },138 139 '3.3' : {140 'OpenGL Shading Language 3.30' : lambda : support_all(['GLSL_3_3', 'GL_ARB_shader_bit_encoding']),141 'New blending functions' : lambda : is_supported('GL_ARB_blend_func_extended'),142 'Pre-assign attribute locations' : lambda : is_supported('GL_ARB_explicit_attrib_location'),143 'Simple boolean occlusion queries' : lambda : is_supported('GL_ARB_occlusion_query2'),144 'Sampler objects' : lambda : is_supported('GL_ARB_sampler_objects'),145 'Unsigned 10.10.10.2 integer textures format' : lambda : is_supported('GL_ARB_texture_rgb10_a2ui'),146 'Swizzle the components of a texture' : lambda : support_one(['GL_ARB_texture_swizzle', 'GL_EXT_texture_swizzle']),147 'Timer query' : lambda : support_one(['GL_ARB_timer_query', 'GL_EXT_timer_query']),148 'Instanced array' : lambda : is_supported('GL_ARB_instanced_arrays'),149 'New 2.10.10.10 vertex attribute data formats' : lambda : is_supported('GL_ARB_vertex_type_2_10_10_10_rev'),150 },151 '4.0' : {152 'OpenGL Shading Language 4.0' : lambda : support_all(['GLSL_4_0', 'GL_ARB_texture_query_lod']),153 'Set individual blend equations/functions for each color output' : lambda : support_one(['GL_ARB_draw_buffers_blend', 'GL_AMD_draw_buffers_blend']),154 'Supplying the arguments to a drawing command from buffer object' : lambda : is_supported('GL_ARB_draw_indirect'),155 'GPU Shader 5' : lambda : is_supported('GL_ARB_gpu_shader5'),156 'Double-precision floating-point types in shaders' : lambda : is_supported('GL_ARB_gpu_shader_fp64'),157 'Explicitly shading at samples' : lambda : is_supported('GL_ARB_sample_shading'),158 'Support for indirect subroutine calls in shaders' : lambda : is_supported('GL_ARB_shader_subroutine'),159 'Tessellation stages' : lambda : support_one(['GL_ARB_tessellation_shader', 'GL_AMD_vertex_shader_tessellator']),160 'Three-component buffer texture formats' : lambda : is_supported('GL_ARB_texture_buffer_object_rgb32'),161 'Cube map array textures' : lambda : is_supported('GL_ARB_texture_cube_map_array'),162 'textureGather in shaders' : lambda : support_one(['GL_ARB_texture_gather', 'GL_AMD_texture_texture4']),163 'Additional transform feedback functionality': lambda : support_one(['GL_ARB_transform_feedback2', 'GL_ARB_transform_feedback3', 'GL_NV_transform_feedback2']),164 },165 '4.1' : {166 'Improved OpenGL ES 2.0 compatibility' : lambda : is_supported('GL_ARB_ES2_compatibility'),167 'Binary represtation of a program object' : lambda : is_supported('GL_ARB_get_program_binary'),168 'Separately shader objects for different shader stages' : lambda : support_one(['GL_ARB_separate_shader_objects', 'GL_EXT_separate_shader_objects']),169 'Precision requirements for shaders' : lambda : is_supported('GL_ARB_shader_precision'),170 '64-bit fp components for VS inputs' : lambda : support_one(['GL_ARB_vertex_attrib_64bit', 'GL_EXT_vertex_attrib_64bit']),171 'Multiple viewports' : lambda : is_supported ('GL_ARB_viewport_array'),172 },173 '4.2' : {174 'BPTC compressed textures' : lambda : is_supported('GL_ARB_texture_compression_bptc'),175 'Allow pixel storage parameters to affect packing and unpacking of compressed textures' : lambda : is_supported('GL_ARB_compressed_texture_pixel_storage'),176 'Shader atomic counters' : lambda : is_supported('GL_ARB_shader_atomic_counters'),177 'Immutable texture images' : lambda : is_supported('GL_ARB_texture_storage'),178 'Instanced transformed feedback drawing' : lambda : is_supported('GL_ARB_transform_feedback_instanced'),179 'Allow the offset within buffer objects used for instanced rendering to be specified' : lambda : is_supported('GL_ARB_base_instance'),180 'Loads from and stores to textures from shader' : lambda : support_one(['GL_ARB_shader_image_load_store', 'GL_EXT_shader_image_load_store']),181 'Add new layout qualifiers to communicate what kind of changes will be made to gl_FragDepth' : lambda : support_one(['GL_ARB_conservative_depth', 'GL_AMD_conservative_depth']),182 'GLSL 4.20 feature pack' : lambda : is_supported('GL_ARB_shading_language_420pack'),183 'Queries for sample counts available for a given internal format and usage' : lambda : is_supported('GL_ARB_internalformat_query'),184 'More restrictive alignment constraints for mapped buffers' : lambda : is_supported('GL_ARB_map_buffer_alignment'),185 },186 '4.3' : {187 'Allows multi-dimensional arrays in GLSL' : lambda : is_supported('GL_ARB_arrays_of_arrays'),188 'OpenGL ES 3.0 compatibility' : lambda : is_supported('GL_ARB_ES3_compatibility'),189 'Clear a buffer object with a constant value' : lambda : is_supported('GL_ARB_clear_buffer_object'),190 'Compute shader' : lambda : is_supported('GL_ARB_compute_shader'),191 'Direct copy of pixels between textures and render buffers' : lambda : support_one(['GL_ARB_copy_image', 'GL_NV_copy_image']),192 'Enhanced debug context' : lambda : is_supported('GL_KHR_debug'),193 'Debug output' : lambda : is_supported('GL_ARB_debug_output'),194 'Set location of a default-block uniform in the shader' : lambda : is_supported('GL_ARB_explicit_uniform_location'),195 'gl_Layer and gl_ViewportIndex in fragment shader' : lambda : is_supported('GL_ARB_fragment_layer_viewport'),196 'Framebuffer without attachment' : lambda : is_supported('GL_ARB_framebuffer_no_attachments'),197 'Find out actual supported limits for most texture parameters' : lambda : is_supported('GL_ARB_internalformat_query2'),198 'Invalidate all or some of the contents of textures and buffers' : lambda : is_supported('GL_ARB_invalidate_subdata'),199 'Draw many GPU generated objects with one call' : lambda : support_one(['GL_ARB_multi_draw_indirect', 'GL_AMD_multi_draw_indirect']),200 'Shader reflection' : lambda : is_supported('GL_ARB_program_interface_query'),201 'Restricted shader read/write to an object' : lambda : is_supported('GL_ARB_robust_buffer_access_behavior'),202 'Query size of an image in a shader' : lambda : is_supported('GL_ARB_shader_image_size'),203 'Enables all shader stages to read and write arbitrarily to buffers' : lambda : is_supported('GL_ARB_shader_storage_buffer_object'),204 'Read stencil bits of a packed depth-stencil texture' : lambda : is_supported('GL_ARB_stencil_texturing'),205 'Create texture buffer object corresponding to a subrange of a buffer\'s data store' : lambda : is_supported('GL_ARB_texture_buffer_range'),206 'Query number of mipmap levels accessible through a sampler uniform' : lambda : is_supported('GL_ARB_texture_query_levels'),207 'Immutable storage objects for multisampled textures' : lambda : is_supported('GL_ARB_texture_storage_multisample'),208 'Provide different ways to interpret texture data without duplicating the texture' : lambda : is_supported('GL_ARB_texture_view'),209 'Separate vertex attribute state from the data stores of each array' : lambda : is_supported('GL_ARB_vertex_attrib_binding'),210 },211 '4.4' : {212 'Buffer storage' : lambda : is_supported('GL_ARB_buffer_storage'),213 'Clear a texture' : lambda : is_supported('GL_ARB_clear_texture'),214 'Enhanced layouts' : lambda : is_supported('GL_ARB_enhanced_layouts'),215 'Multi-bind' : lambda : is_supported('GL_ARB_multi_bind'),216 'Query buffer object' : lambda : support_one(['GL_ARB_query_buffer_object', 'GL_AMD_query_buffer_object']),217 'Texture mirror clamp to edge' : lambda : support_one(['GL_ARB_texture_mirror_clamp_to_edge', 'GL_EXT_texture_mirror_clamp', 'GL_ATI_texture_mirror_once']),218 'Stencil8 format texture' : lambda : is_supported('GL_ARB_texture_stencil8'),219 'B10G11R11F format for vertex' : lambda : is_supported('GL_ARB_vertex_type_10f_11f_11f_rev'),220 },221 '4.5' : {222 'Clip control' : lambda : is_supported('GL_ARB_clip_control'),223 'Cull distance' : lambda : is_supported('GL_ARB_cull_distance'),224 'OpenGL ES 3.1 compatibility' : lambda : is_supported('GL_ARB_ES3_1_compatibility'),225 'Conditional Rendering inverted' : lambda : is_supported('GL_ARB_conditional_render_inverted'),226 'Context flush control' : lambda : support_one(['GL_KHR_context_flush_control', 'GL_ARB_context_flush_control']),227 'GLSL Derivative control' : lambda : is_supported('GL_ARB_derivative_control'),228 'Direct state access' : lambda : support_one(['GL_ARB_direct_state_access', 'GL_EXT_direct_state_access']),229 'Get texture sub image' : lambda : is_supported('GL_ARB_get_texture_sub_image'),230 'Robustness' : lambda : support_one(['GL_KHR_robustness', 'GL_ARB_robustness']),231 'GLSL texture image samples' : lambda : is_supported('GL_ARB_shader_texture_image_samples'),232 'Texture barrier' : lambda : support_one(['GL_ARB_texture_barrier', 'GL_NV_texture_barrier']),233 },234 '4.6' : {235 'Indirect parameters' : lambda : is_supported('GL_ARB_indirect_parameters'),236 'Pipeline statistics query' : lambda : is_supported('GL_ARB_pipeline_statistics_query'),237 'Polygon offset clamp' : lambda : support_one(['GL_ARB_polygon_offset_clamp', 'GL_EXT_polygon_offset_clamp']),238 'No error context' : lambda : is_supported('GL_KHR_no_error'),239 'Shader atomic counter ops' : lambda : is_supported('GL_ARB_shader_atomic_counter_ops'),240 'Shader draw parameters' : lambda : is_supported('GL_ARB_shader_draw_parameters'),241 'Shader group vote' : lambda : is_supported('GL_ARB_shader_group_vote'),242 'SPIR-V' : lambda : is_supported('GL_ARB_gl_spirv'),243 'SPIR-V extensions' : lambda : is_supported('GL_ARB_spirv_extensions'),244 'Texture filter anisotropic' : lambda : support_one(['GL_ARB_texture_filter_anisotropic', 'GL_EXT_texture_filter_anisotropic']),245 'Transform feedback overflow query' : lambda : is_supported('GL_ARB_transform_feedback_overflow_query'),246 }247}248class information:249 def __init__(self):250 self.vendor = ''251 self.renderer = ''252 self.major_ver = 0253 self.minor_ver = 0254 self.glsl_major_ver = 0255 self.glsl_minor_ver = 0256 self.exts = []257 self.feature_infos = []258 def to_html(self, stream):259 stream.write('<html>\n')...

Full Screen

Full Screen

test_specialized.py

Source:test_specialized.py Github

copy

Full Screen

1# encoding: utf-82from contextlib import contextmanager3from datetime import date4from itertools import chain5import pytest6from django import VERSION as DJANGO_VERSION7from django.db.models import Q8from django.utils.translation import trans_real9from queryable_properties.compat import nullcontext10from queryable_properties.utils import get_queryable_property11from ..app_management.models import VersionWithClassBasedProperties12pytestmark = [pytest.mark.django_db, pytest.mark.usefixtures('versions')]13class TestValueCheckProperty(object):14 @pytest.mark.parametrize('index, is_alpha, is_beta, is_stable, is_unstable, released_in_2018', [15 (0, False, True, False, True, False),16 (1, False, False, True, False, False),17 (2, False, False, True, False, True),18 (3, True, False, False, True, True),19 ])20 def test_getter(self, versions, index, is_alpha, is_beta, is_stable, is_unstable, released_in_2018):21 version = versions[index]22 assert version.is_alpha is is_alpha23 assert version.is_beta is is_beta24 assert version.is_stable is is_stable25 assert version.is_unstable is is_unstable26 assert version.shares_common_data is True27 assert version.released_in_2018 is released_in_201828 @pytest.mark.parametrize('condition, expected_versions', [29 (Q(is_alpha=True), {'2.0.0'}),30 (Q(is_beta=True), {'1.2.3'}),31 (Q(is_stable=True), {'1.3.0', '1.3.1'}),32 (Q(is_unstable=True), {'1.2.3', '2.0.0'}),33 (Q(is_alpha=True) | Q(is_beta=True), {'1.2.3', '2.0.0'}),34 (Q(is_stable=False), {'1.2.3', '2.0.0'}),35 (Q(is_alpha=False), {'1.2.3', '1.3.0', '1.3.1'}),36 (Q(shares_common_data=False), set()),37 ])38 def test_filter(self, condition, expected_versions):39 results = VersionWithClassBasedProperties.objects.filter(condition)40 assert len(results) == len(expected_versions) * 241 assert set(result.version for result in results) == expected_versions42 @pytest.mark.skipif(DJANGO_VERSION < (1, 9), reason="Transforms and lookup couldn't be combined before Django 1.9")43 @pytest.mark.parametrize('condition, expected_versions', [44 (Q(released_in_2018=True), {'1.3.1', '2.0.0'}),45 (Q(released_in_2018=True, is_alpha=True), {'2.0.0'}),46 (Q(released_in_2018=False), {'1.2.3', '1.3.0'}),47 ])48 def test_filter_based_on_transform(self, condition, expected_versions):49 results = VersionWithClassBasedProperties.objects.filter(condition)50 assert len(results) == len(expected_versions) * 251 assert set(result.version for result in results) == expected_versions52 @pytest.mark.skipif(DJANGO_VERSION < (1, 8), reason="Expression-based annotations didn't exist before Django 1.8")53 @pytest.mark.parametrize('ordering, expected_version_order', [54 (('-is_stable', '-version'), ['1.3.1', '1.3.0', '2.0.0', '1.2.3']),55 (('-is_unstable', '-is_alpha', 'version'), ['2.0.0', '1.2.3', '1.3.0', '1.3.1']),56 ])57 def test_annotation(self, ordering, expected_version_order):58 results = VersionWithClassBasedProperties.objects.order_by(*ordering)59 # There are 2 objects for each version number.60 expected_version_order = list(chain(*zip(expected_version_order, expected_version_order)))61 assert [result.version for result in results] == expected_version_order62 @pytest.mark.skipif(DJANGO_VERSION < (1, 9), reason="Transforms and lookup couldn't be combined before Django 1.9")63 def test_annotation_based_on_transform(self):64 results = VersionWithClassBasedProperties.objects.order_by('released_in_2018', '-version')65 assert [result.version for result in results] == [66 '1.3.0', '1.3.0', '1.2.3', '1.2.3', '2.0.0', '2.0.0', '1.3.1', '1.3.1'67 ]68class TestRangeCheckProperty(object):69 def test_final_value(self, monkeypatch):70 prop = get_queryable_property(VersionWithClassBasedProperties, 'is_supported')71 assert prop.final_value == date(2019, 1, 1)72 monkeypatch.setattr(prop, 'value', lambda: 5)73 assert prop.final_value == 574 @pytest.mark.parametrize(75 'index, prop_name, value, include_boundaries, include_missing, in_range, expected_result',76 [77 (3, 'is_supported', date(2019, 1, 1), True, True, True, True),78 (3, 'is_supported', date(2019, 1, 1), True, True, False, False),79 (3, 'is_supported', date(2019, 1, 1), True, False, True, False),80 (0, 'supported_in_2018', 2018, True, True, True, False),81 (3, 'supported_in_2018', 2018, False, True, True, False),82 (0, 'supported_in_2018', 2018, True, True, False, True),83 (3, 'supported_in_2018', 2018, True, False, False, True),84 (0, 'is_supported', date(2016, 12, 31), True, True, True, True),85 (0, 'is_supported', date(2016, 12, 31), True, True, False, False),86 (0, 'is_supported', date(2016, 12, 31), False, True, True, False),87 (0, 'is_supported', date(2016, 12, 31), False, True, False, True),88 (3, 'is_supported', date(2018, 11, 1), True, True, True, True),89 (3, 'is_supported', date(2018, 11, 1), True, True, False, False),90 (3, 'is_supported', date(2018, 11, 1), False, True, True, False),91 (3, 'is_supported', date(2018, 11, 1), False, True, False, True),92 ]93 )94 def test_getter(self, monkeypatch, versions, index, prop_name, value, include_boundaries, include_missing,95 in_range, expected_result):96 version = versions[index]97 prop = get_queryable_property(VersionWithClassBasedProperties, prop_name)98 monkeypatch.setattr(prop, 'value', value)99 monkeypatch.setattr(prop, 'include_boundaries', include_boundaries)100 monkeypatch.setattr(prop, 'include_missing', include_missing)101 monkeypatch.setattr(prop, 'in_range', in_range)102 assert getattr(version, prop_name) is expected_result103 @pytest.mark.parametrize('value, include_boundaries, include_missing, in_range, condition, expected_versions', [104 (date(2019, 1, 1), True, True, True, Q(is_supported=True), {'2.0.0'}),105 (date(2019, 1, 1), True, True, True, Q(is_supported=True, major=1), set()),106 (date(2019, 1, 1), False, True, True, Q(is_supported=True), {'2.0.0'}),107 (date(2019, 1, 1), True, True, True, Q(is_supported=False), {'1.2.3', '1.3.0', '1.3.1'}),108 (date(2019, 1, 1), True, True, False, Q(is_supported=True), {'1.2.3', '1.3.0', '1.3.1'}),109 (date(2019, 1, 1), True, True, False, Q(is_supported=False), {'2.0.0'}),110 (date(2019, 1, 1), True, False, True, Q(is_supported=True), set()),111 (date(2019, 1, 1), True, False, False, Q(is_supported=True), {'1.2.3', '1.3.0', '1.3.1', '2.0.0'}),112 (date(2016, 12, 31), True, True, True, Q(is_supported=True), {'1.2.3'}),113 (date(2016, 12, 31), True, True, False, Q(is_supported=True), {'1.3.0', '1.3.1', '2.0.0'}),114 (date(2016, 12, 31), False, True, True, Q(is_supported=True), set()),115 (date(2016, 12, 31), False, True, False, Q(is_supported=True), {'1.2.3', '1.3.0', '1.3.1', '2.0.0'}),116 (date(2018, 11, 1), True, True, True, Q(is_supported=True), {'1.3.1', '2.0.0'}),117 (date(2018, 11, 1), True, True, False, Q(is_supported=True), {'1.2.3', '1.3.0'}),118 (date(2018, 11, 1), False, True, True, Q(is_supported=True), {'1.3.1'}),119 (date(2018, 11, 1), False, True, False, Q(is_supported=True), {'1.2.3', '1.3.0', '2.0.0'}),120 ])121 def test_filter(self, monkeypatch, value, include_boundaries, include_missing, in_range, condition,122 expected_versions):123 prop = get_queryable_property(VersionWithClassBasedProperties, 'is_supported')124 monkeypatch.setattr(prop, 'value', value)125 monkeypatch.setattr(prop, 'include_boundaries', include_boundaries)126 monkeypatch.setattr(prop, 'include_missing', include_missing)127 monkeypatch.setattr(prop, 'in_range', in_range)128 results = VersionWithClassBasedProperties.objects.filter(condition)129 assert set(version.version for version in results) == expected_versions130 @pytest.mark.skipif(DJANGO_VERSION < (1, 9), reason="Transforms and lookup couldn't be combined before Django 1.9")131 @pytest.mark.parametrize('include_boundaries, include_missing, in_range, condition, expected_versions', [132 (True, True, True, Q(supported_in_2018=True), {'1.3.1', '2.0.0'}),133 (True, True, True, Q(supported_in_2018=True, major=1), {'1.3.1'}),134 (True, True, True, Q(supported_in_2018=False), {'1.2.3', '1.3.0'}),135 (True, False, True, Q(supported_in_2018=True), {'1.3.1'}),136 (False, True, True, Q(supported_in_2018=True), set()),137 (True, True, False, Q(supported_in_2018=True), {'1.2.3', '1.3.0'}),138 (True, True, False, Q(supported_in_2018=False), {'1.3.1', '2.0.0'}),139 (True, False, False, Q(supported_in_2018=True), {'1.2.3', '1.3.0', '2.0.0'}),140 ])141 def test_filter_based_on_transform(self, monkeypatch, include_boundaries, include_missing, in_range, condition,142 expected_versions):143 prop = get_queryable_property(VersionWithClassBasedProperties, 'supported_in_2018')144 monkeypatch.setattr(prop, 'include_boundaries', include_boundaries)145 monkeypatch.setattr(prop, 'include_missing', include_missing)146 monkeypatch.setattr(prop, 'in_range', in_range)147 results = VersionWithClassBasedProperties.objects.filter(condition)148 assert set(version.version for version in results) == expected_versions149 @pytest.mark.skipif(DJANGO_VERSION < (1, 8), reason="Expression-based annotations didn't exist before Django 1.8")150 def test_annotation(self):151 results = VersionWithClassBasedProperties.objects.order_by('-is_supported', 'version')152 assert list(results.select_properties('version').values_list('version', flat=True)) == [153 '2.0.0', '2.0.0', '1.2.3', '1.2.3', '1.3.0', '1.3.0', '1.3.1', '1.3.1'154 ]155 @pytest.mark.skipif(DJANGO_VERSION < (1, 9), reason="Transforms and lookup couldn't be combined before Django 1.9")156 def test_annotation_based_on_transform(self):157 results = VersionWithClassBasedProperties.objects.order_by('-supported_in_2018', 'version')158 assert list(results.select_properties('version').values_list('version', flat=True)) == [159 '1.3.1', '1.3.1', '2.0.0', '2.0.0', '1.2.3', '1.2.3', '1.3.0', '1.3.0'160 ]161class TestMappingProperty(object):162 TRANSLATION_TERMS = ('Alpha', 'Beta', 'Stable')163 @contextmanager164 def apply_dummy_translations(self):165 catalog_dict = trans_real.catalog()._catalog166 if hasattr(catalog_dict, '_catalogs'):167 catalog_dict = catalog_dict._catalogs[0]168 for term in self.TRANSLATION_TERMS:169 catalog_dict[term] = term[1:]170 yield171 for term in self.TRANSLATION_TERMS:172 del catalog_dict[term]173 @pytest.mark.parametrize('apply_dummy_translations, expected_verbose_names', [174 (False, ['Beta', 'Stable', 'Stable', 'Alpha']),175 (True, ['eta', 'table', 'table', 'lpha']),176 ])177 def test_getter(self, versions, apply_dummy_translations, expected_verbose_names):178 with self.apply_dummy_translations() if apply_dummy_translations else nullcontext():179 for i, expected_verbose_name in enumerate(expected_verbose_names):180 assert str(versions[i].release_type_verbose_name) == expected_verbose_name181 @pytest.mark.parametrize('apply_dummy_translations', [False, True])182 def test_getter_default(self, versions, apply_dummy_translations):183 versions[0].release_type = 'x'184 with self.apply_dummy_translations() if apply_dummy_translations else nullcontext():185 assert versions[0].release_type_verbose_name is None186 @pytest.mark.skipif(DJANGO_VERSION < (1, 8), reason="Expression-based annotations didn't exist before Django 1.8")187 @pytest.mark.parametrize('apply_dummy_translations, filter_value, expected_count', [188 (False, 'Alpha', 2),189 (False, 'Stable', 4),190 (True, 'eta', 2),191 (True, 'table', 4),192 ])193 def test_filter(self, apply_dummy_translations, filter_value, expected_count):194 with self.apply_dummy_translations() if apply_dummy_translations else nullcontext():195 queryset = VersionWithClassBasedProperties.objects.filter(release_type_verbose_name=filter_value)196 assert queryset.count() == expected_count197 @pytest.mark.skipif(DJANGO_VERSION < (1, 8), reason="Expression-based annotations didn't exist before Django 1.8")198 @pytest.mark.parametrize('apply_dummy_translations', [False, True])199 def test_filter_default(self, versions, apply_dummy_translations):200 versions[0].release_type = 'x'201 versions[0].save()202 with self.apply_dummy_translations() if apply_dummy_translations else nullcontext():203 assert VersionWithClassBasedProperties.objects.get(release_type_verbose_name=None) == versions[0]204 @pytest.mark.skipif(DJANGO_VERSION < (1, 8), reason="Expression-based annotations didn't exist before Django 1.8")205 @pytest.mark.parametrize('apply_dummy_translations, expected_verbose_names', [206 (False, ['Beta', 'Stable', 'Stable', 'Alpha']),207 (True, ['eta', 'table', 'table', 'lpha']),208 ])209 def test_annotation(self, applications, apply_dummy_translations, expected_verbose_names):210 with self.apply_dummy_translations() if apply_dummy_translations else nullcontext():211 queryset = VersionWithClassBasedProperties.objects.order_by('major', 'minor', 'patch')212 queryset = queryset.filter(application=applications[0]).select_properties('release_type_verbose_name')213 assert list(queryset.values_list('release_type_verbose_name', flat=True)) == expected_verbose_names214 @pytest.mark.skipif(DJANGO_VERSION < (1, 8), reason="Expression-based annotations didn't exist before Django 1.8")215 @pytest.mark.parametrize('apply_dummy_translations', [False, True])216 def test_annotation_default(self, versions, apply_dummy_translations):217 versions[0].release_type = 'x'218 versions[0].save()219 with self.apply_dummy_translations() if apply_dummy_translations else nullcontext():220 queryset = VersionWithClassBasedProperties.objects.select_properties('release_type_verbose_name')...

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