Best Python code snippet using autotest_python
config.py
Source: config.py
1import sys, os, modulefinder, pkgutil, subprocess23from . import etc_default4from . import etc56test_should_clobber_config = False7if "UNIT_TEST" in globals():8 if UNIT_TEST:9 if pkgutil.find_loader("config.etc_test_overrides"):10 pkgutil.find_loader("config.etc_test_overrides").load()11 test_should_clobber_config = True121314class configuration:1516 @staticmethod17 def check_packages():18 mdfinder = modulefinder.ModuleFinder(path=['..',])19 builtin_packages = sys.builtin_module_names20 installed_packages = [x[1] for x in pkgutil.iter_modules()]21 here_packages = [x[1] for x in pkgutil.iter_modules()]2223 # installed_packages=pip.get_installed_distributions()24 # installed_packages=[x.project_name for x in installed_packages]25 required_modules = set()26 for root, dirs, files in os.walk("..", followlinks=False):27 for fil in files:28 if fil.endswith(".py"):29 print(os.path.join(root, fil))30 mdfinder.run_script(os.path.join(root, fil))31 top_packages = [32 x.split(".")[0] for x in list(mdfinder.modules.keys())33 ]34 required_modules |= set(top_packages)3536 modules_needed = []37 for mod in required_modules:38 if (39 (mod not in builtin_packages)40 and (mod not in installed_packages)41 and (mod not in here_packages)42 ):43 modules_needed.append(mod)44 if modules_needed:45 print("FATAL CONFIGURATION ERROR !")46 print("The following modules need to be installed for Infoshopkeeper to run.")47 print("Use pip, apt-get, conda or your preferred package manager to download.")48 for m in modules_needed:49 print(("%s is not installed" % m))50 sys.exit(0)5152 @staticmethod53 def improper_config_die(var):54 print("FATAL CONFIGURATION ERROR !")55 print("Unable to reach configuration value %s" % var)56 print(" (did you modify the config before using ? did you used an")57 print(58 " obsolete config file ?)"59 )60 print("\n\n\n")61 sys.exit(0)6263 @staticmethod64 def no_sql_die(sql_type):65 print("FATAL CONFIGURATION ERROR !")66 print("infoshopkeeper requires MySQL, PostGreSQL or sqlite to be installed.")67 print("""You are configured to use sql database type '%s' and it is not installed \n68 or not reachable via your system path.""")6970 @staticmethod71 def get(var):72 if test_should_clobber_config and hasattr(etc_tst, var):73 return getattr(etc_tst, var)74 elif hasattr(etc, var):75 return getattr(etc, var)76 elif hasattr(etc_default, var):77 return getattr(etc_default, var)78 else:79 improper_config_die.__func__(var)8081 db_type = get.__func__("dbtype")82 if db_type == "mysql":83 try:84 subprocess.call("mysql --version", shell=True)85 except subprocess.CalledProcessError as e:86 no_sql_die.__func__(db_type)87 elif db_type == "postgres":88 try:89 subprocess.call("postgres -v", shell=True)90 except subprocess.CalledProcessError as e:91 no_sql_die.__func__(db_type)92 elif get("dbytpy") == "sqlite":93 try:94 subprocess.call("sqlite3 -version", shell=True)95 except subprocess.CalledProcessError as e:96 no_sql_die.__func__(db_type)97 else:98 no_sql_die.__func__(db_type)99
...
setup.py
Source: setup.py
1import setuptools2with open("README.md", "r", encoding="utf-8") as fh:3 long_description = fh.read()4 5try:6 # if have requirements.txt file inside the folder7 with open("requirements.txt", "r", encoding="utf-8") as f:8 modules_needed = [i.strip() for i in fh.readlines()] 9except:10 modules_needed = []11setuptools.setup(12 name="exceltopostgresql", # Replace with your own username13 version="0.0.9",14 author="Xiangyong Luo",15 author_email="rochemay@163.com",16 description="This package help to convert your excel files (xlsx,xls,csv) to Postgresql database.",17 long_description=long_description,18 long_description_content_type="text/markdown",19 url="https://github.com/Xiangyongluo/exceltopostgresql",20 21 22 classifiers=[23 "Programming Language :: Python :: 3",24 "License :: OSI Approved :: MIT License",25 "Operating System :: OS Independent",26 ],27 python_requires='>=3.6',28 29 install_requires=modules_needed,30 packages=setuptools.find_packages(),31 include_package_data=True,32 package_data= {'':['*.txt','*.xls','*.xlsx','*.csv'],33 "test_data":['*.txt']}...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!