Best Python code snippet using localstack_python
test_transfer__to_omero.py
Source: test_transfer__to_omero.py
...30 target_id = "G:7:Project:42"31 print(f"Trying to import [{fname}] into [{target_id}] (sha1: {sha1sum})")32 with pytest.raises(ValueError, match="only the upload to 'Dataset' objects"):33 to_omero(omero_conn, target_id, fname)34def _test_import_image(conn, import_image, capfd, expected_stdout, logfile=""):35 """Test importing local files into OMERO and check its properties in OMERO.36 Expected behavior is to import the file, and to print a bunch of specific messages37 to stderr. The test tries to find back the imported object in OMERO and checks if38 the size and fileset count matches the ones defined in the test settings.39 """40 fname = import_image["filename"]41 sha1sum = import_image["sha1sum"]42 target_id = import_image["target_id"]43 print(f"Trying to import [{fname}] into [{target_id}] (sha1: {sha1sum})")44 ret = to_omero(conn, target_id, fname, logfile)45 assert ret is True46 # capsys won't work as it misses the output of subprocesses (the "omero import"47 # call in this case), but using capfd does the job:48 captured = capfd.readouterr().err49 # print(f"import stdout: {captured.out}")50 # print(f"import stderr: {captured.err}")51 if logfile:52 with open(logfile, "r", encoding="utf-8") as infile:53 captured = infile.read()54 for pattern in expected_stdout:55 assert pattern in captured56 ds_id = target_id.split(":")[-1]57 imported = find_recently_imported(conn, ds_id, os.path.basename(fname))58 assert imported is not None59 files_info = imported.getImportedFilesInfo()60 assert files_info["count"] == import_image["fset_count"]61 assert files_info["size"] == import_image["fset_size"]62@pytest.mark.online63def test_import_image(omero_conn, settings, capfd):64 """Call `_test_import_image()` for each defined import test setting."""65 for import_image in settings.import_image:66 _test_import_image(omero_conn, import_image, capfd, settings.import_messages)67@pytest.mark.online68def test_import_image_log(omero_conn, settings, capfd, tmp_path):69 """Call `_test_import_image()` for one import setting using a log file."""70 import_image = settings.import_image[0]71 logfile = str(tmp_path / "omero-import-debug-log")72 _test_import_image(73 omero_conn, import_image, capfd, settings.import_messages, logfile74 )75@pytest.mark.online76def test_invalid_target(omero_conn, settings, capfd):77 """Test attempting an import to a dataset that can't be written to.78 Expected behavior is to return False and log an error.79 TODO: check what happens if an existing dataset is given, but in a group where the80 user doesn't have permissions!81 """82 expected_output_patterns = [83 "Error on import",84 "ome.formats.importer.ImportLibrary - Exiting on error",85 ]86 import_image = settings.import_image[0]...
ui_import_image.py
Source: ui_import_image.py
1# -*- coding: utf-8 -*-2# Form implementation generated from reading ui file 'ui_import_image.ui'3#4# Created by: PyQt5 UI code generator 5.15.25#6# WARNING: Any manual changes made to this file will be lost when pyuic5 is7# run again. Do not edit this file unless you know what you are doing.8from PyQt5 import QtCore, QtGui, QtWidgets9class Ui_Import_Image(object):10 def setupUi(self, Import_Image):11 Import_Image.setObjectName("Import_Image")12 Import_Image.resize(513, 388)13 self.verticalLayout = QtWidgets.QVBoxLayout(Import_Image)14 self.verticalLayout.setObjectName("verticalLayout")15 self.horizontalLayout = QtWidgets.QHBoxLayout()16 self.horizontalLayout.setObjectName("horizontalLayout")17 self.horizontalLayout_2 = QtWidgets.QHBoxLayout()18 self.horizontalLayout_2.setObjectName("horizontalLayout_2")19 self.label_2 = QtWidgets.QLabel(Import_Image)20 self.label_2.setObjectName("label_2")21 self.horizontalLayout_2.addWidget(self.label_2)22 self.line_patient_id = QtWidgets.QLineEdit(Import_Image)23 self.line_patient_id.setReadOnly(True)24 self.line_patient_id.setObjectName("line_patient_id")25 self.horizontalLayout_2.addWidget(self.line_patient_id)26 self.horizontalLayout.addLayout(self.horizontalLayout_2)27 self.horizontalLayout_3 = QtWidgets.QHBoxLayout()28 self.horizontalLayout_3.setObjectName("horizontalLayout_3")29 self.label_3 = QtWidgets.QLabel(Import_Image)30 self.label_3.setObjectName("label_3")31 self.horizontalLayout_3.addWidget(self.label_3)32 self.line_patient_name = QtWidgets.QLineEdit(Import_Image)33 self.line_patient_name.setReadOnly(True)34 self.line_patient_name.setObjectName("line_patient_name")35 self.horizontalLayout_3.addWidget(self.line_patient_name)36 self.horizontalLayout.addLayout(self.horizontalLayout_3)37 self.verticalLayout.addLayout(self.horizontalLayout)38 self.line_4 = QtWidgets.QFrame(Import_Image)39 self.line_4.setFrameShape(QtWidgets.QFrame.HLine)40 self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)41 self.line_4.setObjectName("line_4")42 self.verticalLayout.addWidget(self.line_4)43 self.horizontalLayout_14 = QtWidgets.QHBoxLayout()44 self.horizontalLayout_14.setObjectName("horizontalLayout_14")45 self.label_12 = QtWidgets.QLabel(Import_Image)46 self.label_12.setObjectName("label_12")47 self.horizontalLayout_14.addWidget(self.label_12)48 spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)49 self.horizontalLayout_14.addItem(spacerItem)50 self.btn_add_image = QtWidgets.QPushButton(Import_Image)51 self.btn_add_image.setObjectName("btn_add_image")52 self.horizontalLayout_14.addWidget(self.btn_add_image)53 self.verticalLayout.addLayout(self.horizontalLayout_14)54 self.wtable_album = QtWidgets.QTableWidget(Import_Image)55 sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)56 sizePolicy.setHorizontalStretch(0)57 sizePolicy.setVerticalStretch(0)58 sizePolicy.setHeightForWidth(self.wtable_album.sizePolicy().hasHeightForWidth())59 self.wtable_album.setSizePolicy(sizePolicy)60 self.wtable_album.setBaseSize(QtCore.QSize(0, 0))61 self.wtable_album.setLayoutDirection(QtCore.Qt.LeftToRight)62 self.wtable_album.setAutoFillBackground(False)63 self.wtable_album.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)64 self.wtable_album.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustIgnored)65 self.wtable_album.setObjectName("wtable_album")66 self.wtable_album.setColumnCount(3)67 self.wtable_album.setRowCount(0)68 item = QtWidgets.QTableWidgetItem()69 self.wtable_album.setHorizontalHeaderItem(0, item)70 item = QtWidgets.QTableWidgetItem()71 self.wtable_album.setHorizontalHeaderItem(1, item)72 item = QtWidgets.QTableWidgetItem()73 self.wtable_album.setHorizontalHeaderItem(2, item)74 self.wtable_album.horizontalHeader().setVisible(False)75 self.wtable_album.horizontalHeader().setDefaultSectionSize(70)76 self.wtable_album.horizontalHeader().setHighlightSections(True)77 self.wtable_album.horizontalHeader().setMinimumSectionSize(70)78 self.wtable_album.horizontalHeader().setStretchLastSection(True)79 self.wtable_album.verticalHeader().setVisible(False)80 self.wtable_album.verticalHeader().setStretchLastSection(False)81 self.verticalLayout.addWidget(self.wtable_album)82 self.horizontalLayout_4 = QtWidgets.QHBoxLayout()83 self.horizontalLayout_4.setObjectName("horizontalLayout_4")84 spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)85 self.horizontalLayout_4.addItem(spacerItem1)86 self.btn_cancel = QtWidgets.QPushButton(Import_Image)87 self.btn_cancel.setObjectName("btn_cancel")88 self.horizontalLayout_4.addWidget(self.btn_cancel)89 self.btn_done = QtWidgets.QPushButton(Import_Image)90 self.btn_done.setObjectName("btn_done")91 self.horizontalLayout_4.addWidget(self.btn_done)92 self.verticalLayout.addLayout(self.horizontalLayout_4)93 self.retranslateUi(Import_Image)94 QtCore.QMetaObject.connectSlotsByName(Import_Image)95 def retranslateUi(self, Import_Image):96 _translate = QtCore.QCoreApplication.translate97 Import_Image.setWindowTitle(_translate("Import_Image", "导å
¥å¾å"))98 self.label_2.setText(_translate("Import_Image", "ç¼å·"))99 self.label_3.setText(_translate("Import_Image", "å§å"))100 self.label_12.setText(_translate("Import_Image", "ç¸å"))101 self.btn_add_image.setText(_translate("Import_Image", "æ·»å "))102 item = self.wtable_album.horizontalHeaderItem(0)103 item.setText(_translate("Import_Image", "æ°å»ºå"))104 item = self.wtable_album.horizontalHeaderItem(1)105 item.setText(_translate("Import_Image", "æ°å»ºå"))106 item = self.wtable_album.horizontalHeaderItem(2)107 item.setText(_translate("Import_Image", "æ°å»ºå"))108 self.btn_cancel.setText(_translate("Import_Image", "åæ¶"))...
images.py
Source: images.py
1import scripts.settings as settings2import scripts.gui_tools as gui_tools3class MainImages:4 def __init__(self):5 self.icon = gui_tools.import_image(settings.path.ICON, alpha=True)6class GameImages:7 def __init__(self, color='blue'):8 # TODO determine which COLOR to load9 # GRID10 self.cell_cover = gui_tools.import_image(settings.path.CELL_COVER, settings.CELL_SIZE / 128)11 self.cell_bomb = gui_tools.import_image(settings.path.CELL_BOMB, settings.CELL_SIZE / 128)12 self.cell_exploded_bomb = gui_tools.import_image(settings.path.CELL_EXPLODED_BOMB, settings.CELL_SIZE / 128)13 self.cell_flag = gui_tools.import_image(settings.path.CELL_FLAG, settings.CELL_SIZE / 128)14 self.cell_0 = gui_tools.import_image(settings.path.CELL_0, settings.CELL_SIZE / 128)15 self.cell_1 = gui_tools.import_image(settings.path.CELL_1, settings.CELL_SIZE / 128)16 self.cell_2 = gui_tools.import_image(settings.path.CELL_2, settings.CELL_SIZE / 128)17 self.cell_3 = gui_tools.import_image(settings.path.CELL_3, settings.CELL_SIZE / 128)18 self.cell_4 = gui_tools.import_image(settings.path.CELL_4, settings.CELL_SIZE / 128)19 self.cell_5 = gui_tools.import_image(settings.path.CELL_5, settings.CELL_SIZE / 128)20 self.cell_6 = gui_tools.import_image(settings.path.CELL_6, settings.CELL_SIZE / 128)21 self.cell_7 = gui_tools.import_image(settings.path.CELL_7, settings.CELL_SIZE / 128)22 self.cell_8 = gui_tools.import_image(settings.path.CELL_8, settings.CELL_SIZE / 128)23 # UI24 self.menu = gui_tools.import_image(settings.path.MENU, 0.375, True)25 self.restart = gui_tools.import_image(settings.path.RESTART, 0.375, True)26 # add bomb and num images to cell_dict27 self.cell_dict = {28 -1: self.cell_bomb,29 0: self.cell_0,30 1: self.cell_1,31 2: self.cell_2,32 3: self.cell_3,33 4: self.cell_4,34 5: self.cell_5,35 6: self.cell_6,36 7: self.cell_7,37 8: self.cell_8,38 }39class MenuImages:40 def __init__(self):41 self.play = gui_tools.import_image(settings.path.PLAY_BUTTON, alpha=True)42 self.left_arrow = gui_tools.import_image(settings.path.LEFT_ARROW, alpha=True)43 self.right_arrow = gui_tools.import_image(settings.path.RIGHT_ARROW, alpha=True)44 self.input_box_2_digits = gui_tools.import_image(settings.path.INPUT_BOX_2_DIGITS, alpha=True)45 self.input_box_2_digits_selected = gui_tools.import_image(settings.path.INPUT_BOX_2_DIGITS_SELECTED, alpha=True)46 self.input_box_4_digits = gui_tools.import_image(settings.path.INPUT_BOX_4_DIGITS, alpha=True)...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!