You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
# Select an unused port for serving web pages to the test suite.
14
-
PORT='8081'
35
+
PORT="8081"
36
+
# Use the localhost for testing.
37
+
HOST="http://127.0.0.1:"+PORT
15
38
16
39
17
40
# Provide access to the currently-active ModuleFixture object.
@@ -20,25 +43,32 @@
20
43
21
44
# Define `module fixtures <https://docs.python.org/2/library/unittest.html#setupmodule-and-teardownmodule>`_ to build the test Runestone project, run the server, then shut it down when the tests complete.
22
45
classModuleFixture(unittest.TestCase):
23
-
def__init__(self,
46
+
def__init__(
47
+
self,
24
48
# The path to the Python module in which the test resides. This provides a simple way to determine the path in which to run runestone build/serve.
25
49
module_path,
26
50
# True if the sphinx-build process must exit with status of 0 (success)
# Run the server. Simply calling ``runestone serve`` fails, since the process killed isn't the actual server, but probably a setuptools-created launcher.
# Testing time in dominated by browser startup/shutdown. So, simply run all tests in a module in a single browser instance to speed things up. See ``RunestoneTestCase.setUp`` for additional code to (mostly) clear the browser between tests.
73
105
#
74
106
# `PyVirtualDisplay <http://pyvirtualdisplay.readthedocs.io/en/latest/>`_ only runs on X-windows, meaning Linux. Mac seems to have `some support <https://support.apple.com/en-us/HT201341>`_. Windows is out of the question.
#self.driver = webdriver.PhantomJS() # use this for Jenkins auto testing
112
+
#self.driver = webdriver.PhantomJS() # use this for Jenkins auto testing
81
113
options=Options()
82
114
options.add_argument("--window-size=1200,800")
83
115
options.add_argument("--no-sandbox")
@@ -87,6 +119,17 @@ def setUpModule(self):
87
119
globalmf
88
120
mf=self
89
121
122
+
# Wait for the webserver to come up.
123
+
fortriesinrange(50):
124
+
try:
125
+
urlopen(HOST, timeout=5)
126
+
exceptURLError:
127
+
# Wait for the server to come up.
128
+
time.sleep(0.1)
129
+
else:
130
+
# The server is up. We're done.
131
+
break
132
+
90
133
deftearDownModule(self):
91
134
# Shut down Selenium.
92
135
self.driver.quit()
@@ -113,6 +156,7 @@ def tearDownModule(self):
113
156
defrunTest(self):
114
157
pass
115
158
159
+
116
160
# Provide a simple way to instantiante a ModuleFixture in a test module. Typical use:
117
161
#
118
162
# .. code:: Python
@@ -133,10 +177,10 @@ class RunestoneTestCase(unittest.TestCase):
133
177
defsetUp(self):
134
178
# Use the shared module-wide driver.
135
179
self.driver=mf.driver
136
-
self.host='http://127.0.0.1:'+PORT
180
+
self.host=HOST
137
181
138
182
deftearDown(self):
139
183
# Clear as much as possible, to present an almost-fresh instance of a browser for the next test. (Shutting down then starting up a browswer is very slow.)
0 commit comments