This repository has been archived by the owner on Sep 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
pavement.py
69 lines (51 loc) · 1.57 KB
/
pavement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import sys
import os
import time
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
from paver.easy import task, cmdopts, sh
from paver.tasks import help
@task
@cmdopts([
('port=', 'p', 'port to bind the server, default 8000'),
('daemon', 'd', 'run server on background'),
])
def start(options):
''' Start server '''
import stewie.config
stewie.config.load_settings(os.environ.get('STEWIE_ENV', 'dev'))
from stewie.server import Server
server = Server(port=options.get('port', 8000))
from stewie.lib import daemon
if options.start.get('daemon'):
daemon.daemonize('/tmp/stewie.pid')
try:
server.start()
except KeyboardInterrupt:
server.stop()
@task
@cmdopts([
('keyword=', 'k', 'pass keyword to py.test'),
('noserver', 'n', 'do not start the test server'),
])
def test(options):
''' Run all tests '''
import pytest
import stewie.config
stewie.config.load_settings(os.environ.get('STEWIE_ENV', 'test'))
if not options.get('noserver'):
_start_test_server()
args = ['-vs', 'stewie/tests']
keyword = options.get('keyword')
if keyword:
args.append('-k ' + keyword)
ret = pytest.main(args)
if not options.get('noserver'):
_stop_test_server()
exit(ret)
def _start_test_server():
sh("rm -f tests/server.log")
sh("STEWIE_ENV=test paver start -p7766 & ")
time.sleep(.5)
def _stop_test_server():
sh("ps ax | grep 'paver start -p7766' | grep -v grep | awk '{ print $1 }' | xargs kill")
print "Server logs on tests/server.log"