Skip to content

Commit 4d4bfe2

Browse files
committed
Remove driver code
Since this package is meant to be installed and imported, it doesn't really make sense anymore to have code in the modules that allows those modules to be executed as individual Python scripts. So I'm removing that code in this commit. I considered adding tests to replicate the functionality of the code being removed, but there didn't seem to be much point. The removed code just does a basic check that the server can start and stop, and relies on some external client to send HTTP or SMTP requests, and our existing tests cover all that functionality already.
1 parent 66b6700 commit 4d4bfe2

File tree

3 files changed

+0
-79
lines changed

3 files changed

+0
-79
lines changed

pytest_localserver/http.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import enum
66
import itertools
77
import json
8-
import sys
98
import threading
109

1110
from werkzeug.datastructures import Headers
@@ -161,29 +160,3 @@ def serve_content(self, content, code=200, headers=None, chunked=Chunked.NO, sto
161160
self.store_request_data = store_request_data
162161
if headers:
163162
self.headers = Headers(headers)
164-
165-
166-
if __name__ == "__main__": # pragma: no cover
167-
import os.path
168-
import time
169-
170-
app = ContentServer()
171-
server = WSGIServer(application=app)
172-
server.start()
173-
174-
print("HTTP server is running at %s" % server.url)
175-
print("Type <Ctrl-C> to stop")
176-
177-
try:
178-
path = sys.argv[1]
179-
except IndexError:
180-
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "README.rst")
181-
182-
app.serve_content(open(path).read(), 302)
183-
184-
try:
185-
while True:
186-
time.sleep(1)
187-
except KeyboardInterrupt:
188-
print("\rstopping...")
189-
server.stop()

pytest_localserver/https.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,32 +133,3 @@ def certificate(self):
133133
certificate path across different versions or test runs.
134134
"""
135135
return self._cert
136-
137-
138-
if __name__ == "__main__": # pragma: no cover
139-
140-
import sys
141-
import time
142-
143-
print("Using certificate %s." % DEFAULT_CERTIFICATE)
144-
145-
server = SecureContentServer()
146-
server.start()
147-
server.logging = True
148-
149-
print("HTTPS server is running at %s" % server.url)
150-
print("Type <Ctrl-C> to stop")
151-
152-
try:
153-
path = sys.argv[1]
154-
except IndexError:
155-
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "README.rst")
156-
157-
server.serve_content(open(path).read(), 302)
158-
159-
try:
160-
while True:
161-
time.sleep(1)
162-
except KeyboardInterrupt:
163-
print("\rstopping...")
164-
server.stop()

pytest_localserver/smtp.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,3 @@ def __del__(self):
142142

143143
def __repr__(self): # pragma: no cover
144144
return "<smtp.Server %s:%s>" % self.addr
145-
146-
147-
def main():
148-
import time
149-
150-
server = Server()
151-
server.start()
152-
153-
print("SMTP server is running on %s:%i" % server.addr)
154-
print("Type <Ctrl-C> to stop")
155-
156-
try:
157-
while True:
158-
time.sleep(1)
159-
except KeyboardInterrupt:
160-
pass
161-
finally:
162-
print("\rstopping...")
163-
server.stop()
164-
165-
166-
if __name__ == "__main__": # pragma: no cover
167-
main()

0 commit comments

Comments
 (0)