Best Python code snippet using selene_python
views.py
Source: views.py
...33 return render(request, "detail_matching.html", content)34# matching ìì 35# í´ë¹ matchingì ìì±ìì¸ì§ íì¸í´ì¼ í¨36# matching/delete_matching/<tattooist_id: int>/<matching_id: int>37def delete_matching(request, tattooist_id: int, matching_id: int):38 matching = Matching.objects.get(pk=matching_id)39 # ë§ì½ ë¡ê·¸ì¸íì§ ììê±°ë, ìì±ìê° ìë ê²½ì°40 if not request.user.is_authenticated or request.user.id != matching.author.id:41 return redirect("customer_request_rejected")42 matching.delete()43 return redirect("matching_list")44# customerê° tattooistë§ ì ê·¼ ê°ë¥í 기ë¥ì ì ê·¼íë ê²½ì°45def customer_request_rejected_view(request):46 return render(request, "customer_request_rejected.html")47# ì¡°ê±´ì ë§ë matchingì 리ì¤í¸ë¥¼ paginationì¼ë¡ ë³´ì¬ì£¼ë íì´ì§48# matching/matching_list?region=ì¸ì²&type=미ëíí¬&part=목&order-by=price(ëë pub-date)49def matching_list_view(request):50 content = dict()51 content["is_tattooist"] = (request.user.is_authenticated) and (request.user.is_tattooist)...
matching.py
Source: matching.py
1#!/usr/bin/env python32# *-* coding:utf8 *-*3# sky4from lib import database, log, warning, notification5import os, datetime, re6def matching_record(logger, db, record_time, matching_file, matching_key):7 logger.logger.debug(f"è®°å½å¹é
({matching_file}:{matching_key})ä¿¡æ¯...")8 with open(matching_file, "r") as f:9 sql="select record_filesize from matching where record_time=(select max(record_time) from matching where matching_file=? and matching_key=?) and matching_file=? and matching_key=?"10 record_filesize=db.query_one(sql, (matching_file, matching_key, matching_file, matching_key))[0]11 now_filesize=os.stat(matching_file)[6]12 #logger.logger.info(f"{matching_file=}, {record_filesize=}, {now_filesize=}")13 if now_filesize < record_filesize:14 record_filesize=015 elif now_filesize == record_filesize:16 return17 f.seek(record_filesize)18 lines=f.readlines()19 next_filesize=f.tell()20 #logger.logger.info(f"{matching_file=}, {record_filesize=}, {lines=}, {next_filesize=}")21 warning_flag=022 sql="insert into matching values(?, ?, ?, ?, ?)"23 for line in lines:24 if re.search(matching_key, line):25 warning_flag=126 #logger.logger.warning(f"{matching_file}æ件ä¸åºç°{matching_key}")27 db.update_one(sql, (record_time, matching_file, matching_key, line, next_filesize))28 if warning_flag==0:29 db.update_one(sql, (record_time, matching_file, matching_key, "Nothing", next_filesize))30def matching_records(log_file, log_level, matching_dict):31 logger=log.Logger(log_file, log_level)32 db=database.db()33 record_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")34 for i in matching_dict:35 matching_record(logger, db, record_time, i, matching_dict[i])36def matching_analysis(log_file, log_level, warning_interval, matching_dict, notify_dict):37 logger=log.Logger(log_file, log_level)38 db=database.db()39 for matching_file in matching_dict:40 sql=f"select record_time, matching_context from matching \41 where record_time=( \42 select max(record_time) from matching \43 where matching_context!=? and matching_file=? and matching_key=?\44 )"45 data=db.query_one(sql, ("all", matching_file, matching_dict[matching_file]))46 logger.logger.debug("åæå¹é
...")47 if data is not None:48 if data[1] != 'Nothing':49 warning_msg=f"\"{matching_file}\"æ件ä¸\"{data[1].strip()}\"è¡åå¨å
³é®å\"{matching_dict[matching_file]}\""50 msg=f"{matching_file}_{matching_dict[matching_file]}"51 warning_flag=warning.non_remedial_warning(logger, db, "matching", msg, warning_msg, data[0], warning_interval)52 if warning_flag:53 warning_msg=f"æ¥å¿åæé¢è¦:\n{warning_msg}\n"54 notification.send(logger, warning_msg, notify_dict, msg=msg)55if __name__ == "__main__":...
Check out the latest blogs from LambdaTest on this topic:
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.
Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.
“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
Hey LambdaTesters! We’ve got something special for you this week. ????
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!!