Skip to content

Commit 7eeec13

Browse files
fix typos and grammar
1 parent 9e1aaf1 commit 7eeec13

File tree

340 files changed

+2026
-1994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+2026
-1994
lines changed

_ui_tests/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright: 2012 MoinMoin:HughPerkins
22
# License: GNU GPL v3 (or any later version), see LICENSE.txt for details.
33

4-
"""Contains global configuration for functional tests"""
4+
"""Contains global configuration for functional tests."""
55

66
BASE_URL = "http://localhost:8080/"

_ui_tests/conftest.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# License: GNU GPL v3 (or any later version), see LICENSE.txt for details.
33

44
"""
5-
Contains events called by pytest during the life-cycle of the test suite
5+
Pytest hook definitions used during the lifecycle of the test suite.
6+
67
This module is automatically loaded by pytest, which looks for a file
7-
of this name
8+
with this name.
89
"""
910

1011
import os
@@ -16,15 +17,18 @@
1617

1718
def pytest_runtest_makereport(item, call):
1819
"""
19-
Entry point for event which occurs after each test has run
20-
The parameters are:
21-
- item: the method called
22-
- call: an object of type CallInfo, which has two properties, of which
23-
excinfo contains info about any exception that got thrown by the method
24-
This method is called automatically by pytest. The name of the method
25-
is used by pytest to locate it, and decide when to call it
26-
This specific method instance is used to take a screenshot whenever a test
27-
fails, ie whenever the method throws an exception
20+
Entry point for the event that occurs after each test has run.
21+
22+
Parameters:
23+
- item: the test function being executed
24+
- call: a CallInfo object; its excinfo attribute contains information about
25+
any exception raised by the test
26+
27+
This function is called automatically by pytest. The function name is used
28+
by pytest to locate it and to decide when to call it.
29+
30+
This hook is used to take a screenshot whenever a test fails, i.e., whenever
31+
the test raises an exception.
2832
"""
2933
if call.excinfo is not None:
3034
if driver_register.get_driver() is not None and hasattr(item, "obj"):

_ui_tests/driver_register.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
# License: GNU GPL v3 (or any later version), see LICENSE.txt for details.
33

44
"""
5-
This module is used to register the webdriver driver module as a global
6-
variable, so that it can be used by conftest methods, eg for doing a
7-
printscreen when a test fails
5+
Register the WebDriver instance as a global so it can be accessed by
6+
conftest hooks, e.g., to take a screenshot when a test fails.
87
"""
98

109
driver = None
1110

1211

1312
def register_driver(driver_):
1413
"""
15-
set the driver global variable to driver_
14+
Set the global driver variable to driver_.
1615
"""
1716
global driver
1817
driver = driver_
1918

2019

2120
def get_driver():
2221
"""
23-
get the value of the driver global variable
22+
Get the value of the global driver variable.
2423
"""
2524
global driver
2625
return driver

_ui_tests/test_subitems.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Copyright: 2012 MoinMoin:HughPerkins
22
# License: GNU GPL v3 (or any later version), see LICENSE.txt for details.
33

4-
"""Functional test: create subitem"""
4+
"""Functional test: create subitem."""
55

66
import config
77
import utils
88

99

1010
class TestSubitems:
11-
"""Functional test: create subitem"""
11+
"""Functional test: create subitem."""
1212

1313
def setup_class(self):
14-
"""opens browser and creates some random item names for these tests"""
14+
"""Open the browser and create random item names for these tests."""
1515
self.driver = utils.create_browser()
1616
self.base_url = config.BASE_URL
1717
self.base_item_name = "page_" + utils.generate_random_word(5)
1818
self.subitem_name = "subitem_" + utils.generate_random_word(5)
1919

2020
def create_wiki_item(self, item_name):
21-
"""Creates a new wiki item with name 'item_name'"""
21+
"""Create a new wiki item with the name 'item_name'."""
2222
driver = self.driver
2323

2424
driver.get(self.base_url + "/" + item_name)
@@ -29,7 +29,7 @@ def create_wiki_item(self, item_name):
2929
driver.find_element_by_id("f_submit").click()
3030

3131
def test_createsubitem(self):
32-
"""Test create subitem"""
32+
"""Test creating a subitem."""
3333
driver = self.driver
3434

3535
self.create_wiki_item(self.base_item_name)
@@ -48,14 +48,14 @@ def test_createsubitem(self):
4848
assert driver.title.split(" - ")[0] == self.base_item_name + "/" + self.subitem_name
4949

5050
def teardown_class(self):
51-
"""shuts down browser"""
51+
"""Shut down the browser."""
5252
self.driver.quit()
5353

5454

5555
if __name__ == "__main__":
56-
# This lets us run the test directly, without using pytest
57-
# This is useful for example for being able to call help, eg
58-
# 'help(driver)', or 'help(driver.find_element_by_id("f_submit"))'
56+
# This lets us run the test directly, without using pytest.
57+
# This is useful, for example, for being able to call help, e.g.,
58+
# 'help(driver)' or 'help(driver.find_element_by_id("f_submit"))'.
5959
testSubitems = TestSubitems()
6060
testSubitems.setup_class()
6161
testSubitems.test_createsubitem()

_ui_tests/utils.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright: 2012 MoinMoin:HughPerkins
33
# License: GNU GPL v3 (or any later version), see LICENSE.txt for details.
44

5-
"""Functions to facilitate functional testing"""
5+
"""Functions to facilitate functional testing."""
66

77
import random
88
import urllib.request, urllib.parse, urllib.error
@@ -24,31 +24,30 @@
2424

2525
def create_browser():
2626
"""
27-
Instantiates a firefox browser object, and configures it for English language
28-
and registers it for screenshots, and sets the timeout
27+
Instantiate a Firefox browser object, configure it for English,
28+
register it for screenshots, and set the timeout.
2929
"""
3030
profile = webdriver.FirefoxProfile()
3131
profile.set_preference("intl.accept_languages", "en")
3232
driver = webdriver.Firefox(firefox_profile=profile)
33-
driver_register.register_driver(driver) # register with
34-
# driver_register, which is needed so that printscreen on test
35-
# failure works
33+
driver_register.register_driver(driver) # Register with driver_register so that
34+
# taking a screenshot on test failure works.
3635
driver.implicitly_wait(20)
3736
return driver
3837

3938

4039
def generate_random_word(length):
4140
"""
42-
generates a random string containing numbers, of length 'length'
41+
Generate a random numeric string of length 'length'.
4342
"""
4443
word = str(random.randint(10 ** (length - 1), 10**length))
4544
return word
4645

4746

4847
def generate_random_name(prefix, totallength):
4948
"""
50-
create a random name, starting with 'prefix'
51-
of total length 'totallength'
49+
Create a random name starting with 'prefix',
50+
with a total length of 'totallength'.
5251
"""
5352
length = totallength - len(prefix)
5453
numberword = generate_random_word(length)

contrib/css-lint/lint-prep.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
Reads a variables.css file and a common.css (or theme.css) file, outputs a lint.css file
3-
similar to the common.css file but having all var(...) expressions replaced with the values
4-
within the variables.css file. The output file can then be submitted to a css validator.
2+
Reads a variables.css file and a common.css (or theme.css) file, and outputs a lint.css file
3+
similar to common.css but with all var(...) expressions replaced with the values
4+
from variables.css. The output file can then be submitted to a CSS validator.
55
6-
This program will be obsolete when a css lint program supports variables.
6+
This program will be obsolete when a CSS lint program supports variables.
77
"""
88

99
variables_in = "../../src/moin/static/css/variables.css"
@@ -37,7 +37,7 @@ def parse_variables():
3737

3838
def create_lint(vars):
3939
"""
40-
Read css file and replace variable names with values.
40+
Read the CSS file and replace variable names with values.
4141
"""
4242
with open(css_in) as f:
4343
lines = f.readlines()

contrib/loadtesting/locust/locustfile.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
These comments are also used as content when moin items are created; the result is
1717
a small load is placed upon the Whoosh indexer.
1818
19-
The primary goal of this test is to create a server overload. A server overload will likely take the
19+
The primary goal of this test is to create a server overload. A server overload will likely take the
2020
form of a LockError in the Whoosh AsyncWriter (/whoosh/writing.py). Each thread attempting
2121
to update the Whoosh index tries to obtain the write lock for a short period of time (~5
2222
seconds). If the lock is not obtained, a LockError exception is raised and the console log
2323
will show a traceback with the message "server overload or corrupt index". The item was
24-
saved but cannot be accessed because it is not in the index - to correct the error,
25-
stop the server, rebuild the indexes, restart the server.
24+
saved but cannot be accessed because it is not in the index to correct the error,
25+
stop the server, rebuild the indexes, and restart the server.
2626
2727
The maximum load that the wiki server can process is established by trial and error.
28-
With the default wait_time of 2-3 seconds running 3 symultaneous users will create a load of about
28+
With the default wait_time of 23 seconds, running 3 simultaneous users will create a load of about
2929
one transaction per second. Running 30 users could create a load of about 10
3030
transactions per second - but this may be reduced because the wiki server will have slow responses.
3131
@@ -39,13 +39,13 @@
3939
and create wiki items as part of the test. It is best to start with
4040
an empty wiki (./m new-wiki).
4141
42-
Each locust user registers a new id, creates and updates a home page in the user namespace,
43-
creates and updates a <username> item in the default namespace, and logs-out.
42+
Each Locust user registers a new ID, creates and updates a home page in the user namespace,
43+
creates and updates a <username> item in the default namespace, and logs out.
4444
45-
Because each locust user is working on unique items, it does not test edit locking. Use locustfile2.py
46-
to stress test edit locking.
45+
Because each Locust user is working on unique items, it does not test edit locking. Use locustfile2.py
46+
to stress-test edit locking.
4747
48-
To load test Moin2:
48+
To load-test Moin 2:
4949
* read about Locust at https://docs.locust.io/en/stable/index.html - last tested with Locust 2.9.0
5050
* install Locust per the docs in its own venv
5151
* open a terminal window and start the Moin built-in server (./m run)
@@ -62,28 +62,28 @@
6262
* customize and repeat:
6363
* ./m del-wiki
6464
* ./m new-wiki
65-
* restart Moin2 buit-in server
65+
* restart the Moin 2 built-in server
6666
* restart Locust server
6767
* refresh browser window
6868
"""
6969

7070

71-
# used to create unique user IDs
71+
# Used to create unique user IDs
7272
user_number = 0
73-
# min and max wait time in seconds between user transactions, ignored, there is only 1 task
73+
# Min and max wait time in seconds between user transactions; ignored, there is only 1 task
7474
wait_time = between(2, 3)
75-
# sleep time between GET, POST requests in seconds
75+
# Sleep time between GET and POST requests, in seconds
7676
sleep_time = 0
7777

7878

7979
class LoadTest(HttpUser):
8080
"""
8181
First, create a Home page in the default and user namespaces.
8282
83-
Next create a workflow for each locust user that will
84-
register a new user, login, create a user home page,
85-
modify user home page several times,
86-
create a new item, modify new item several times, and logout.
83+
Next, create a workflow for each Locust user that will
84+
register a new user, log in, create a user home page,
85+
modify the user home page several times,
86+
create a new item, modify the new item several times, and log out.
8787
"""
8888

8989
@events.test_start.add_listener
@@ -207,7 +207,7 @@ def click_post_login(self):
207207
print("%s: response.status_code = %s" % (sys._getframe().f_lineno, response.status_code))
208208

209209
def create_home_page(self):
210-
# click link to users home page (home page has not been created: 404 expected)
210+
# Click link to the user's home page (home page has not been created: 404 expected)
211211
with self.client.get(self.user_home_page, catch_response=True) as response:
212212
if response.status_code == 404:
213213
response.success()
@@ -249,7 +249,7 @@ def create_home_page(self):
249249
print("%s: response.status_code = %s" % (sys._getframe().f_lineno, response.status_code))
250250

251251
def modify_home_page(self, idx):
252-
# get users home page
252+
# Get the user's home page
253253
with self.client.get(self.user_home_page, catch_response=True) as response:
254254
if response.status_code != 200:
255255
print("%s: response.status_code = %s" % (sys._getframe().f_lineno, response.status_code))
@@ -267,7 +267,7 @@ def modify_home_page(self, idx):
267267
home_page,
268268
{
269269
"content_form_data_text": test_content % (self.user_name, self.get_time() + " idx=%s" % idx),
270-
"comment": "my homepage comment",
270+
"comment": "my home page comment",
271271
"submit": "OK",
272272
"meta_form_contenttype": "text/x.moin.wiki;charset=utf-8",
273273
"meta_form_itemtype": "default",

0 commit comments

Comments
 (0)