QA/Execution/Web Testing/Docs/Automation/StyleGuide: Difference between revisions

Jump to navigation Jump to search
Line 10: Line 10:
* Each file should have a completed copy of the [http://www.mozilla.org/MPL/2.0/ MPL2]
* Each file should have a completed copy of the [http://www.mozilla.org/MPL/2.0/ MPL2]
* Each file should pass [http://www.python.org/dev/peps/pep-0008/ PEP8] except for line length, see below.   
* Each file should pass [http://www.python.org/dev/peps/pep-0008/ PEP8] except for line length, see below.   
** I.e. parameters  should have a comma and a space e.g.
<pre class="brush:py;toolbar:false;">
<pre class="brush:py;toolbar:false;">
     # Good
     # Good
Line 19: Line 18:
</pre>
</pre>
** Lines should try not to have more than 100 characters.
** Lines should try not to have more than 100 characters.
** Docstrings should conform to [http://www.python.org/dev/peps/pep-0257/ PEP0257] and should be on a single line wherever possible.
<pre class="brush:py;toolbar:false;">
    # Good
    def click_login():
    """Clicks the login link."""
    # Bad
    def click_login():
    """
    Clicks the login link.
    """
</pre>
Where not possible, the first line should be a summary.
<pre class="brush:py;toolbar:false;">
    # Good
    def login():
    """Logs in.
    Clicks the login link and then waits for the home page to load.
    """
    # Bad
    def login():
    """Logs in.
    Clicks the login link and then waits for the home page to load."""
</pre>
** Indenting should be a soft tab (4 spaces) as common with in Python. Do not mix tabs and spaces!
** Indenting should be a soft tab (4 spaces) as common with in Python. Do not mix tabs and spaces!
** There should be no whitespace at the end of the file (as per PEP8)
** There should be no whitespace at the end of the file (as per PEP8)
Confirmed users
2,197

edits

Navigation menu