Confirmed users
2,197
edits
| 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"> | ||
# Good | |||
def method(self, parameter) | |||
# Bad | |||
def method(self,parameter) | |||
</ | </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"> | ||
# Good | |||
def click_login(): | |||
"""Clicks the login link.""" | |||
# Bad | |||
def click_login(): | |||
""" | |||
Clicks the login link. | |||
""" | |||
</ | </source> | ||
Where not possible, the first line should be a summary. | Where not possible, the first line should be a summary. | ||
< | <source lang="python"> | ||
# 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> | </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). | ||
* 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"> | ||
# Good | |||
class TestThisSite: | |||
# Bad | |||
class test_this_site: | |||
</ | </source> | ||
= Page Objects = | = Page Objects = | ||