Skip to content

Commit 2674d56

Browse files
committed
Move SMTP driver code into a function
pytest_localserver.smtp allows running itself as a module to start up an SMTP server, which is implemented by a bit of driver code guarded by an `if __name__ == "__main__"` block. Typical best practice is to put that code in a `main()` function, which is what I'm doing in this commit.
1 parent 7b6de78 commit 2674d56

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest_localserver/smtp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __repr__(self): # pragma: no cover
156156
return "<smtp.Server %s:%s>" % self.addr
157157

158158

159-
if __name__ == "__main__": # pragma: no cover
159+
def main():
160160
import time
161161

162162
server = Server()
@@ -178,3 +178,7 @@ def __repr__(self): # pragma: no cover
178178
# support for Python 2.4 dictates that try ... finally is not used
179179
# together with any except statements
180180
pass
181+
182+
183+
if __name__ == "__main__": # pragma: no cover
184+
main()

0 commit comments

Comments
 (0)