diff options
author | Jauhien Piatlicki (jauhien) <piatlicki@gmail.com> | 2013-07-02 12:22:15 +0200 |
---|---|---|
committer | Jauhien Piatlicki (jauhien) <piatlicki@gmail.com> | 2013-07-02 12:22:15 +0200 |
commit | 70190446ac3e2be5fc946da165a9eb81d8d6594b (patch) | |
tree | f3a7a3e597e9d0b811c5acf3fbf552bdc36cbf70 /tests | |
parent | README: dependency on dev-python/sexpdata (diff) | |
download | g-sorcery-70190446ac3e2be5fc946da165a9eb81d8d6594b.tar.gz g-sorcery-70190446ac3e2be5fc946da165a9eb81d8d6594b.tar.bz2 g-sorcery-70190446ac3e2be5fc946da165a9eb81d8d6594b.zip |
tests/server: separate http server
Diffstat (limited to 'tests')
-rw-r--r-- | tests/server.py | 26 | ||||
-rw-r--r-- | tests/test_package_db.py | 17 |
2 files changed, 28 insertions, 15 deletions
diff --git a/tests/server.py b/tests/server.py new file mode 100644 index 0000000..ba4ed99 --- /dev/null +++ b/tests/server.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" + server.py + ~~~~~~~~~ + + test server + + :copyright: (c) 2013 by Jauhien Piatlicki + :license: GPL-2, see LICENSE for more details. +""" + +import http.server, threading + +class Server(threading.Thread): + def __init__(self): + super().__init__() + server_address = ('127.0.0.1', 8080) + self.httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler) + + def run(self): + self.httpd.serve_forever() + + def shutdown(self): + self.httpd.shutdown() diff --git a/tests/test_package_db.py b/tests/test_package_db.py index 2994157..1433eb7 100644 --- a/tests/test_package_db.py +++ b/tests/test_package_db.py @@ -11,24 +11,11 @@ :license: GPL-2, see LICENSE for more details. """ -import json, http.server, os, shutil, tempfile, threading, \ - unittest +import json, os, shutil, tempfile, unittest from g_sorcery import package_db, exceptions - -class Server(threading.Thread): - def __init__(self): - super().__init__() - server_address = ('127.0.0.1', 8080) - self.httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler) - - def run(self): - self.httpd.serve_forever() - - def shutdown(self): - self.httpd.shutdown() - +from tests.server import Server class DummyDB(package_db.PackageDB): def __init__(self, directory, packages): |