Best Python code snippet using autotest_python
djangoctl.py
Source: djangoctl.py
...21class Django(func_module.FuncModule):22 version = "0.0.1"23 api_version = "0.0.1"24 description = "Django control module."25 def _verify_path(self, project_path):26 """27 Verifies the project path exists and is readable.28 project_path is the path to the Django project.29 """30 # Verify path exists31 if not os.access(project_path, os.F_OK):32 raise exceptions.OSError(33 "Path %s doesn't exist." % project_path)34 # .. and that we can read it35 if not os.access(project_path, os.R_OK):36 raise exceptions.OSError(37 "Path %s is not readable." % project_path)38 return True39 def _get_settings(self, project_path):40 """41 Gets the settings object.42 project_path is the path to the Django project.43 """44 self._verify_path(project_path)45 # Append the settings to the path46 sys.path.append(project_path)47 import settings48 del sys.path[-1]49 return settings50 def settings(self, project_path):51 """52 Simple gets the settings for a specific application.53 project_path is the path to the Django project.54 """55 self._verify_path(project_path)56 settings = self._get_settings(project_path)57 items = {}58 # for each item in settings attempt to append the setting to items59 for item in dir(settings):60 # ... assuming it isn't _*61 if item[1] != '_':62 setting = getattr(settings, item)63 # See if we can directly append64 if type(setting) in [types.TupleType,65 types.StringType,66 types.DictType,67 types.ListType]:68 items[item] = setting69 else:70 # Else force it to a string71 items[item] = str(setting)72 # Remove the settings from the path73 return items74 def setting(self, project_path, a_setting):75 """76 Returns a single setting.77 project_path is the path to the Django project.78 """79 items = self.settings(project_path)80 return items[a_setting]81 def manage(self, project_path, command):82 """83 Executes django-admin.py adding the path and settings84 variables for a command.85 project_path is the path to the Django project.86 command is the command to run.87 """88 self._verify_path(project_path)89 settings = self._get_settings(project_path)90 command = "django-admin.py %s --pythonpath=%s --settings=settings" % (91 command, project_path)92 cmdref = sub_process.Popen(command.split(), stdout=sub_process.PIPE,93 stderr=sub_process.PIPE, shell=False,94 close_fds=True)95 data = cmdref.communicate()96 return (cmdref.returncode, data[0], data[1])97 def environment(self, project_path):98 """99 Gets the environment information that the project is running on.100 project_path is the path to the Django project.101 """102 self._verify_path(project_path)103 import platform104 from django import get_version105 return {'django_version': get_version(),106 'uname': platform.uname(),107 'dist': platform.dist(),...
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.
Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!
Desired Capabilities is a class used to declare a set of basic requirements such as combinations of browsers, operating systems, browser versions, etc. to perform automated cross browser testing of a web application.
Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.
It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?
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!!