pytest-girder 3.2.19.dev38__tar.gz → 3.2.19.dev46__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_girder-3.2.19.dev38/pytest_girder.egg-info → pytest_girder-3.2.19.dev46}/PKG-INFO +1 -1
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder/fixtures.py +7 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder/utils.py +62 -45
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46/pytest_girder.egg-info}/PKG-INFO +1 -1
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/scm_version.json +2 -2
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/LICENSE +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/MANIFEST.in +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pyproject.toml +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder/__init__.py +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder/assertions.py +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder/plugin.py +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder/plugin_registry.py +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder/web_client.py +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/SOURCES.txt +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/dependency_links.txt +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/entry_points.txt +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/requires.txt +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/scm_file_list.json +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/top_level.txt +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/setup.cfg +0 -0
- {pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/setup.py +0 -0
|
@@ -83,8 +83,15 @@ def db(request):
|
|
|
83
83
|
|
|
84
84
|
# Clear connection cache and model singletons
|
|
85
85
|
_dbClients.clear()
|
|
86
|
+
# Only keep the most recent instance of each model class. Older instances
|
|
87
|
+
# can no longer be reached through event bindings (which are keyed by
|
|
88
|
+
# handler name and replaced by newer instances), and reconnecting all of
|
|
89
|
+
# them in every test makes each test slower than the last.
|
|
90
|
+
latest = {}
|
|
86
91
|
for model in model_base._modelSingletons:
|
|
87
92
|
model.__class__._instance = None
|
|
93
|
+
latest[model.__class__] = model
|
|
94
|
+
model_base._modelSingletons[:] = latest.values()
|
|
88
95
|
|
|
89
96
|
if mockDb:
|
|
90
97
|
pymongo.MongoClient = realMongoClient
|
|
@@ -2,18 +2,65 @@ import base64
|
|
|
2
2
|
import cherrypy
|
|
3
3
|
import contextlib
|
|
4
4
|
import email
|
|
5
|
-
import errno
|
|
6
5
|
import io
|
|
7
6
|
import json
|
|
8
|
-
import os
|
|
9
7
|
import queue
|
|
10
8
|
import socket
|
|
9
|
+
import socketserver
|
|
11
10
|
import threading
|
|
12
11
|
import time
|
|
13
12
|
import urllib.parse
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
class _MockSmtpHandler(socketserver.StreamRequestHandler):
|
|
16
|
+
"""
|
|
17
|
+
Handle a single SMTP session, accepting every message and placing its data
|
|
18
|
+
on the server's mail queue. Only the subset of SMTP used by smtplib to
|
|
19
|
+
send unauthenticated, unencrypted mail is implemented.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def _reply(self, line):
|
|
23
|
+
self.wfile.write(line.encode('ascii') + b'\r\n')
|
|
24
|
+
|
|
25
|
+
def handle(self):
|
|
26
|
+
self._reply('220 localhost Mock SMTP server ready')
|
|
27
|
+
while True:
|
|
28
|
+
line = self.rfile.readline()
|
|
29
|
+
if not line:
|
|
30
|
+
return
|
|
31
|
+
command = line.strip().split(b' ', 1)[0].upper()
|
|
32
|
+
if command in (b'HELO', b'EHLO'):
|
|
33
|
+
self._reply('250 localhost')
|
|
34
|
+
elif command in (b'MAIL', b'RCPT', b'RSET', b'NOOP'):
|
|
35
|
+
self._reply('250 OK')
|
|
36
|
+
elif command == b'DATA':
|
|
37
|
+
self._reply('354 End data with <CR><LF>.<CR><LF>')
|
|
38
|
+
lines = []
|
|
39
|
+
while True:
|
|
40
|
+
line = self.rfile.readline()
|
|
41
|
+
if not line:
|
|
42
|
+
return
|
|
43
|
+
if line in (b'.\r\n', b'.\n'):
|
|
44
|
+
break
|
|
45
|
+
# Undo dot-stuffing (RFC 5321 section 4.5.2)
|
|
46
|
+
if line.startswith(b'.'):
|
|
47
|
+
line = line[1:]
|
|
48
|
+
lines.append(line)
|
|
49
|
+
self.server.mailQueue.put(b''.join(lines))
|
|
50
|
+
self._reply('250 OK')
|
|
51
|
+
elif command == b'QUIT':
|
|
52
|
+
self._reply('221 Bye')
|
|
53
|
+
return
|
|
54
|
+
else:
|
|
55
|
+
self._reply('502 Command not implemented')
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class _MockSmtpServer(socketserver.ThreadingTCPServer):
|
|
59
|
+
daemon_threads = True
|
|
60
|
+
|
|
61
|
+
def __init__(self, address):
|
|
62
|
+
self.mailQueue = queue.Queue()
|
|
63
|
+
super().__init__(address, _MockSmtpHandler)
|
|
17
64
|
|
|
18
65
|
|
|
19
66
|
class MockSmtpReceiver:
|
|
@@ -24,52 +71,19 @@ class MockSmtpReceiver:
|
|
|
24
71
|
|
|
25
72
|
def start(self):
|
|
26
73
|
"""
|
|
27
|
-
Start the mock SMTP server
|
|
28
|
-
|
|
29
|
-
the current process so as to reduce potential conflicts with parallel
|
|
30
|
-
tests that are started nearly simultaneously.
|
|
74
|
+
Start the mock SMTP server on an available port. The bound host and
|
|
75
|
+
port are available as the ``address`` attribute.
|
|
31
76
|
"""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
import smtpd
|
|
37
|
-
|
|
38
|
-
class MockSmtpServer(smtpd.SMTPServer):
|
|
39
|
-
mailQueue = queue.Queue()
|
|
40
|
-
|
|
41
|
-
def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
|
|
42
|
-
self.mailQueue.put(data)
|
|
43
|
-
|
|
44
|
-
for porttry in range(_maxTries):
|
|
45
|
-
port = _startPort + ((porttry + os.getpid()) % _maxTries)
|
|
46
|
-
try:
|
|
47
|
-
self.address = ('localhost', port)
|
|
48
|
-
self.smtp = MockSmtpServer(self.address, None)
|
|
49
|
-
break
|
|
50
|
-
except OSError as e:
|
|
51
|
-
if e.errno != errno.EADDRINUSE:
|
|
52
|
-
raise
|
|
53
|
-
else:
|
|
54
|
-
raise Exception('Could not bind to any port for Mock SMTP server')
|
|
55
|
-
|
|
56
|
-
self.thread = threading.Thread(target=self.loop)
|
|
77
|
+
self.smtp = _MockSmtpServer(('localhost', 0))
|
|
78
|
+
self.address = ('localhost', self.smtp.server_address[1])
|
|
79
|
+
self.thread = threading.Thread(target=self.smtp.serve_forever, kwargs={
|
|
80
|
+
'poll_interval': 0.1}, daemon=True)
|
|
57
81
|
self.thread.start()
|
|
58
82
|
|
|
59
|
-
def loop(self):
|
|
60
|
-
# See comment in start about import scoping
|
|
61
|
-
import asyncore
|
|
62
|
-
|
|
63
|
-
"""
|
|
64
|
-
Instead of calling asyncore.loop directly, wrap it with a small
|
|
65
|
-
timeout. This prevents using 100% cpu and still allows a graceful exit.
|
|
66
|
-
"""
|
|
67
|
-
while len(asyncore.socket_map):
|
|
68
|
-
asyncore.loop(timeout=0.5, use_poll=True)
|
|
69
|
-
|
|
70
83
|
def stop(self):
|
|
71
84
|
"""Stop the mock STMP server"""
|
|
72
|
-
self.smtp.
|
|
85
|
+
self.smtp.shutdown()
|
|
86
|
+
self.smtp.server_close()
|
|
73
87
|
self.thread.join()
|
|
74
88
|
|
|
75
89
|
def getMail(self, parse=False):
|
|
@@ -334,6 +348,9 @@ def serverContext(plugins=None, bindPort=False):
|
|
|
334
348
|
cherrypy.engine.unsubscribe('stop', girder.events.daemon.stop)
|
|
335
349
|
cherrypy.engine.stop()
|
|
336
350
|
cherrypy.engine.exit()
|
|
351
|
+
# Since the daemon was unsubscribed from the engine, stop it explicitly
|
|
352
|
+
# so its thread doesn't linger after the test.
|
|
353
|
+
girder.events.daemon.stop()
|
|
337
354
|
cherrypy.tree.apps = {}
|
|
338
355
|
# This is needed to allow cherrypy to restart on another port
|
|
339
356
|
cherrypy.server.httpserver = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/requires.txt
RENAMED
|
File without changes
|
{pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/scm_file_list.json
RENAMED
|
File without changes
|
{pytest_girder-3.2.19.dev38 → pytest_girder-3.2.19.dev46}/pytest_girder.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|