Best Python code snippet using pyatom_python
combobox.py
Source:combobox.py  
1#!/usr/bin/env python2#3#  Linux Desktop Testing Project http://www.gnomebangalore.org/ldtp4#5#  Description:6#  This set of test scripts will test the LDTP framework for correct7#  functioning of its APIs. This is a Regression Suite.8#9#  Author:10#     Prashanth Mohan  <prashmohan@gmail.com>11#12#13#  This test script is free software; you can redistribute it and/or14#  modify it under the terms of the GNU Library General Public15#  License as published by the Free Software Foundation; either16#  version 2 of the License, or (at your option) any later version.17#18#  This library is distributed in the hope that it will be useful,19#  but WITHOUT ANY WARRANTY; without even the implied warranty of20#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU21#  Library General Public License for more details.22#23#  You should have received a copy of the GNU Library General Public24#  License along with this library; if not, write to the25#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,26#  Boston, MA 02111-1307, USA.27#28from regression import *29import tempfile30try:31    check_open('gedit')32except:33    raise34data_object     = LdtpDataFileParser (datafilename)35value           = data_object.gettagvalue ('language')36text            = data_object.gettagvalue ('text')37if value == []:38    value = 'C'39else:40    value = value[0]41if text == []:42    text = 'test text'43else:44    text = text[0]45    46pref = '*Pref*'47log ('comboselect','teststart')48try:49    if guiexist (pref) == 0:50        open_pref()51    if selecttab (pref,'ptl0','Syntax Highlighting') != 1:52        log ('Unable to select tab','cause')53        raise LdtpExecutionError (str (traceback.format_exc ()))54    if comboselect (pref,'cboHighlightmode',value) != 1:55        log ('Undefined return value','cause')56        raise LdtpExecutionError (str (traceback.format_exc ()))57    verifyselect (pref,'cboHighlightmode', value)58except:59    testfail ('comboselect')60    raise LdtpExecutionError (str (traceback.format_exc ()))61testpass ('comboselect')62log ('capturetofile','teststart')63try:64    file_name = tempfile.NamedTemporaryFile()65    if capturetofile (pref,'cboHighlightmode',file_name.name) != 1:66        log ('Undefined return Value','cause')67        raise LdtpExecutionError (str (traceback.format_exc ()))68    contents = file_name.file.read().split('\n')[:-1]69    for value in contents:70        comboselect (pref,'cboHighlightmode',value)71        #time.sleep (1)72        verifyselect (pref,'cboHighlightmode', value)73    click (pref,'btnClose')74    file_name.close ()75except:76    testfail ('capturetofile')77    raise LdtpExecutionError (str (traceback.format_exc ()))78testpass ('capturetofile')79        80## http://bugzilla.gnome.org/show_bug.cgi?id=35214981log ('selectindex','teststart')82try:83    selectmenuitem ('*gedit','mnuSearch;mnuFind')84    index = 085    file_name = tempfile.NamedTemporaryFile()86    waittillguiexist ('*Find')87    if capturetofile ('*Find','cboSearchfor',file_name.name) != 1:88        log ('Undefined return Value','cause')89        raise LdtpExecutionError (str (traceback.format_exc ()))90    contents = file_name.file.read().split('\n')91    for value in contents:92        if selectindex ('*Find', 'cboSearchfor', index) != 1:93            log ('Undefined return value','cause')94            raise LdtpExecutionError (str (traceback.format_exc ()))95        #time.sleep (1)96        verifyselect ('*Find', 'cboSearchfor', value)97except:98    testfail ('selectindex')99    raise LdtpExecutionError (str (traceback.format_exc ()))100testpass ('selectindex')101        102log ('settextvalue on combobox','teststart')103try:104    if guiexist ('*Find') != 1:105        log ('Find window not open','cause')106        raise LdtpExecutionError ('Find window not open')107    if settextvalue ('*Find','cboSearchfor', text) != 1:108        log ('settextvalue failed','cause')109        raise LdtpExecutionError ('settextvalue failed')110    #time.sleep (0)111    verifyselect ('*Find', 'cboSearchfor', text)112except:113    testfail ('settextvalue on combobox')114    raise LdtpExecutionError (str (traceback.format_exc ()))115testpass ('settextvalue on combobox')116log ('showlist','teststart')117try:118    if showlist ('*Find','cboSearchfor') != 1:119        log ('Undefined return value','cause')120        raise LdtpExecutionError (str (traceback.format_exc ()))121    #time.sleep (1)122    if verifyshowlist ('*Find','cboSearchfor') != 1:123        log ('List not being shown','cause')124        raise LdtpExecutionError ('List not being shown')125except:126    testfail ('showlist')127    raise LdtpExecutionError (str (traceback.format_exc ()))128testpass ('showlist')129log ('hidelist','teststart')130try:131    if hidelist ('*Find','cboSearchfor') != 1:132        log ('Undefined return value','cause')133        raise LdtpExecutionError ('Undefined return value')134    #time.sleep (1)135    if verifyhidelist ('*Find','cboSearchfor') != 1:136        log ('List still being shown','cause')137        raise LdtpExecutionError ('List still being shown')138    click ('*Find','btnClose')139except:140    testfail ('hidelist')141    raise LdtpExecutionError (str (traceback.format_exc ()))...forms.py
Source:forms.py  
1from flask_wtf import FlaskForm2from wtforms import StringField, SelectField3from wtforms.fields import FileField, MultipleFileField4from wtforms.validators import InputRequired, URL, Optional5from form_widgets import *6from models import *7from app import app8class ProjectUploadForm(FlaskForm):9    name = StringField("ÐведиÑе Ð¸Ð¼Ñ Ð¿ÑоекÑа...", widget=VerifyText(), validators=[InputRequired()])10    subject = SelectField("ÐÑедмеÑ:", choices=[(s.id, s.name) for s in Subject.query.order_by('name')], coerce=int,11                          widget=VerifySelect(), validators=[InputRequired()])12    desc = StringField("ÐпиÑание пÑоекÑа: ", widget=VerifyTextArea(), validators=[Optional()])13    project_image = FileField("Ðаглавное изобÑажение ваÑего пÑоекÑа", widget=VerifyFile(), validators=[Optional()],14                              render_kw={'accept': "." + ", .".join(app.config["IMAGE_ALLOWED_EXTENSIONS"])})15    project_files = MultipleFileField("ФайлÑ: ", widget=VerifyFile(multiple=True),16                                      render_kw={'webkitdirectory': True, 'directory': True})...form_widgets.py
Source:form_widgets.py  
1from wtforms.widgets import PasswordInput, CheckboxInput, TextInput, FileInput, RadioInput, TextArea, Select2from wtforms.widgets.html5 import EmailInput3from wtforms.widgets.html5 import URLInput4class VerifyInputMixin:5    def __init__(self, error_class=u"is-invalid", *args, **kwargs):6        super().__init__(*args, **kwargs)7        self.error_class = error_class8    def __call__(self, field, **kwargs):9        if field.errors:10            c = kwargs.pop("class", "") or kwargs.pop("class_", "")11            kwargs["class"] = u"%s %s" % (self.error_class, c)12        return super().__call__(field, **kwargs)13class VerifyTextArea(VerifyInputMixin, TextArea):14    pass15class VerifyEmail(VerifyInputMixin, EmailInput):16    pass17class VerifyPassword(VerifyInputMixin, PasswordInput):18    pass19class VerifyBoolean(VerifyInputMixin, CheckboxInput):20    pass21class VerifyText(VerifyInputMixin, TextInput):22    pass23class VerifyFile(VerifyInputMixin, FileInput):24    pass25class VerifyRadio(VerifyInputMixin, RadioInput):26    pass27class VerifySelect(VerifyInputMixin, Select):28    pass29class VerifyURL(VerifyInputMixin, URLInput):...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!!
