-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a test layer that sets up a server on a known port
- Loading branch information
1 parent
8b653f2
commit 68b86c6
Showing
4 changed files
with
56 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from zope.app.server.main import setup, load_options, run | ||
import ThreadedAsync.LoopCallback | ||
import threading | ||
from zope.testbrowser.realproxy import TARGET_PORT | ||
|
||
class TestbrowserRealClass: | ||
|
||
__bases__ = () | ||
|
||
def __init__(self): | ||
self.__name__ = self.__class__.__name__[:-5] | ||
self.__module__ = self.__class__.__module__ | ||
|
||
def setUp(self): | ||
self.startZope() | ||
|
||
def tearDown(self): | ||
self.stopZope() | ||
|
||
def startZope(self, fg=None): | ||
"""start Zope in a daemon thread""" | ||
def go(): | ||
# force the server to run on a known port | ||
args = ['-X', 'server/address=%s' % TARGET_PORT, | ||
'-X', 'site-definition=ftesting.zcml'] | ||
setup(load_options(args)) | ||
run() | ||
|
||
self.zope_thread = threading.Thread(target=go) | ||
self.zope_thread.setDaemon(True) | ||
self.zope_thread.start() | ||
|
||
def stopZope(self): | ||
"""tell Zope to stop and wait for it to do so""" | ||
ThreadedAsync.LoopCallback.exit_status = 0 | ||
self.zope_thread.join() | ||
|
||
TestbrowserReal = TestbrowserRealClass() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters