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

no edit summary
No edit summary
Line 6: Line 6:
* Each file should have a completed copy of the [http://www.mozilla.org/MPL/2.0/ MPL2] license block, immediately followed by an empty line.
* Each file should have a completed copy of the [http://www.mozilla.org/MPL/2.0/ MPL2] license block, immediately followed by an empty line.
* 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.   
<source lang="python">
<source lang="python">
# Good
# Good
Line 13: Line 14:
def method(self,parameter)
def method(self,parameter)
</source>
</source>
* 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.
* Docstrings should conform to [http://www.python.org/dev/peps/pep-0257/ PEP0257] and should be on a single line wherever possible.
<source lang="python">
<source lang="python">
# Good
# Good
Line 26: Line 29:
"""
"""
</source>
</source>
Where not possible, the first line should be a summary.
Where not possible, the first line should be a summary.
<source lang="python">
<source lang="python">
# Good
# Good
Line 41: Line 46:
Clicks the login link and then waits for the home page to load."""
Clicks the login link and then waits for the home page to load."""
</source>
</source>
* 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).
* Comments should be on the line above. Remember to update comments when changing code so that code matches the comments.
* Comments should be on the line above. Remember to update comments when changing code so that code matches the comments.
* Class names should be in Pascal style as this is Python idiomatic.
* Class names should be in Pascal style as this is Python idiomatic.
<source lang="python">
<source lang="python">
# Good
# Good
Confirmed users
2,197

edits