Skip to content

Commit 21d380c

Browse files
author
jmatthews
committed
tidy up plugins
1 parent b1db63b commit 21d380c

File tree

37 files changed

+124
-86
lines changed

37 files changed

+124
-86
lines changed

pytest-fixture-config/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tests *

pytest-fixture-config/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This adds the 'dev' marker to versions.
33
# This must conform to PEP-386:
44
# http://www.python.org/dev/peps/pep-0386/#the-new-versioning-algorithm
5-
tag_build = .dev1
5+
#tag_build = .dev1
66

77
[upload_docs]
88
upload-dir = build/sphinx/html

pytest-fixture-config/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import logging
33

4-
from setuptools import setup, find_packages
4+
from setuptools import setup
55
from setuptools.command.test import test as TestCommand
66

77
classifiers = [

pytest-listener/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tests *

pytest-listener/setup.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
pytest_args = []
2323

24+
2425
class PyTest(TestCommand):
2526

2627
def initialize_options(self):
@@ -38,10 +39,10 @@ def run_tests(self):
3839
import pytest
3940

4041
pytest_args.extend(['--cov', 'pytest_listener',
41-
'--cov-report', 'xml',
42-
'--cov-report', 'html',
43-
'--junitxml', 'junit.xml',
44-
])
42+
'--cov-report', 'xml',
43+
'--cov-report', 'html',
44+
'--junitxml', 'junit.xml',
45+
])
4546
errno = pytest.main(pytest_args)
4647
sys.exit(errno)
4748

pytest-profiling/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tests *

pytest-profiling/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This adds the 'dev' marker to versions.
33
# This must conform to PEP-386:
44
# http://www.python.org/dev/peps/pep-0386/#the-new-versioning-algorithm
5-
tag_build = .dev1
5+
#tag_build = .dev1
66

77
[upload_docs]
88
upload-dir = build/sphinx/html

pytest-pyramid-server/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tests *
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Entrance point for the integration tests
3+
#
4+
from pyramid.response import Response
5+
from pyramid.config import Configurator
6+
7+
8+
def main(global_config, **settings):
9+
config = Configurator(settings=settings,)
10+
config.add_route('home', 'test')
11+
config.add_view(lambda request: Response('OK'), route_name='home')
12+
return config.make_wsgi_app()

pytest-pyramid-server/pytest_pyramid_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def pre_setup(self):
100100
parser.set('server:main', 'port', self.port)
101101
parser.set('server:main', 'host', self.hostname)
102102
[parser.set(section, k, v) for section, cfg in self.extra_config_vars.items() for (k, v) in cfg.items()]
103-
with self.working_config.open('w') as fp:
103+
with open(str(self.working_config), 'w') as fp:
104104
parser.write(fp)
105105

106106
# Set the uri to be the external hostname and the url prefix

pytest-pyramid-server/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This adds the 'dev' marker to versions.
33
# This must conform to PEP-386:
44
# http://www.python.org/dev/peps/pep-0386/#the-new-versioning-algorithm
5-
tag_build = .dev1
5+
#tag_build = .dev1
66

77
[upload_docs]
88
upload-dir = build/sphinx/html

pytest-pyramid-server/setup.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import logging
33

4-
from setuptools import setup, find_packages
4+
from setuptools import setup
55
from setuptools.command.test import test as TestCommand
66

77
classifiers = [
@@ -22,6 +22,7 @@
2222

2323
pytest_args = []
2424

25+
2526
class PyTest(TestCommand):
2627

2728
def initialize_options(self):
@@ -39,10 +40,10 @@ def run_tests(self):
3940
import pytest
4041

4142
pytest_args.extend(['--cov', 'pytest_pyramid_server',
42-
'--cov-report', 'xml',
43-
'--cov-report', 'html',
44-
'--junitxml', 'junit.xml',
45-
])
43+
'--cov-report', 'xml',
44+
'--cov-report', 'html',
45+
'--junitxml', 'junit.xml',
46+
])
4647
errno = pytest.main(pytest_args)
4748
sys.exit(errno)
4849

@@ -61,14 +62,18 @@ def main():
6162
]
6263

6364
tests_require = ['pytest-cov',
64-
'mock'
65+
'pyramid-debugtoolbar',
6566
]
6667

6768
entry_points = {
6869
'pytest11': [
6970
'pyramid_server = pytest_pyramid_server',
70-
]
71+
],
72+
'paste.app_factory': [
73+
'pyramid_server_test = pyramid_server_test:main',
74+
],
7175
}
76+
7277

7378
setup(
7479
name='pytest-pyramid-server',
@@ -84,7 +89,7 @@ def main():
8489
install_requires=install_requires,
8590
tests_require=tests_require,
8691
cmdclass={'test': PyTest},
87-
py_modules=['pytest_pyramid_server'],
92+
py_modules=['pytest_pyramid_server', 'pyramid_server_test'],
8893
entry_points=entry_points,
8994
)
9095

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[app:main]
2+
use = egg:pytest-pyramid-server#pyramid_server_test
3+
url_prefix = test
4+
5+
[server:main]
6+
use = egg:waitress#main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
from pytest_pyramid_server import InlinePyramidTestServer
4+
5+
CONFIG_DIR = os.path.dirname(__file__) + '/config'
6+
7+
8+
def test_InlinePyramidTestServer():
9+
ipts = InlinePyramidTestServer(config_dir=CONFIG_DIR)
10+
ipts.start()
11+
assert ipts.check_server_up()
12+
ipts.kill()
13+
assert not ipts.check_server_up()

pytest-qt-app/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tests *

pytest-qt-app/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This adds the 'dev' marker to versions.
33
# This must conform to PEP-386:
44
# http://www.python.org/dev/peps/pep-0386/#the-new-versioning-algorithm
5-
tag_build = .dev1
5+
#tag_build = .dev1
66

77
[upload_docs]
88
upload-dir = build/sphinx/html

pytest-qt-app/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def main():
6565

6666
entry_points = {
6767
'pytest11': [
68-
'qt = pytest_qt',
68+
'qt = pytest_qt_app',
6969
]
7070
}
7171

pytest-server-fixtures/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tests *

pytest-server-fixtures/pytest_server_fixtures/jenkins.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
import os.path
99
import shutil
1010

11-
try:
12-
import jenkins
13-
except ImportError:
14-
pass
15-
1611
import pytest
1712

1813
from pytest_server_fixtures import CONFIG
@@ -24,8 +19,8 @@
2419
@yield_requires_config(CONFIG, ['jenkins_war', 'java_executable'])
2520
@pytest.yield_fixture(scope='session')
2621
def jenkins_server():
27-
""" Session-scoped Jenkins server instance
28-
22+
""" Session-scoped Jenkins server instance
23+
2924
Attributes
3025
----------
3126
api (`jenkins.Jenkins`) : python-jenkins client API connected to this server
@@ -41,6 +36,8 @@ class JenkinsTestServer(HTTPTestServer):
4136
kill_retry_delay = 2
4237

4338
def __init__(self, **kwargs):
39+
global jenkins
40+
import jenkins
4441
super(JenkinsTestServer, self).__init__(**kwargs)
4542
self.env = dict(JENKINS_ROOT='/usr/share/jenkins',
4643
JENKINS_HOME=self.workspace,
@@ -75,7 +72,7 @@ def load_plugins(self, plugins_repo, plugins=None):
7572

7673
# copy the plugins to the jenkins plugin directory
7774
available_plugins = dict(((os.path.splitext(os.path.basename(x))[0], os.path.join(plugins_repo, x))
78-
for x in os.listdir(plugins_repo) if x.endswith('.hpi')))
75+
for x in os.listdir(plugins_repo) if x.endswith('.hpi')))
7976

8077
if plugins is None:
8178
plugins = available_plugins.keys()

pytest-server-fixtures/pytest_server_fixtures/mongo.py

+16-20
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55

66
import pytest
77

8-
try:
9-
import pymongo
10-
from pymongo.errors import AutoReconnect, ConnectionFailure
11-
except ImportError:
12-
pass
13-
148
from pytest_server_fixtures import CONFIG
159
from pytest_fixture_config import requires_config
1610

@@ -36,11 +30,11 @@ def mongo_server(request):
3630
3731
For completeness, we tidy up any outstanding mongo temp directories
3832
at the start and end of each test session
39-
33+
4034
Attributes
4135
----------
4236
api (`pymongo.MongoClient`) : PyMongo Client API connected to this server
43-
.. also inherits all attributes from the `workspace` fixture
37+
.. also inherits all attributes from the `workspace` fixture
4438
"""
4539
return _mongo_server(request)
4640

@@ -68,6 +62,8 @@ class MongoTestServer(TestServer):
6862
random_port = True
6963

7064
def __init__(self, **kwargs):
65+
global pymongo
66+
import pymongo
7167
mongod_dir = tempfile.mkdtemp(dir=self.get_base_dir())
7268
super(MongoTestServer, self).__init__(workspace=mongod_dir, delete=True, **kwargs)
7369

@@ -85,25 +81,25 @@ def get_base_dir():
8581
@property
8682
def run_cmd(self):
8783
return ['%s/mongod' % CONFIG.mongo_bin,
88-
'--bind_ip=%s' % self.hostname,
89-
'--port=%s' % self.port,
90-
'--dbpath=%s' % self.workspace,
91-
'--nounixsocket',
92-
'--smallfiles',
93-
'--syncdelay', '0',
94-
'--nohttpinterface',
95-
'--nssize=1',
96-
'--nojournal',
97-
'--quiet',
98-
]
84+
'--bind_ip=%s' % self.hostname,
85+
'--port=%s' % self.port,
86+
'--dbpath=%s' % self.workspace,
87+
'--nounixsocket',
88+
'--smallfiles',
89+
'--syncdelay', '0',
90+
'--nohttpinterface',
91+
'--nssize=1',
92+
'--nojournal',
93+
'--quiet',
94+
]
9995

10096
def check_server_up(self):
10197
"""Test connection to the server."""
10298
print("Connecting to Mongo at %s:%s" % (self.hostname, self.port))
10399
try:
104100
self.api = pymongo.MongoClient(self.hostname, self.port)
105101
return True
106-
except (AutoReconnect, ConnectionFailure) as e:
102+
except (pymongo.AutoReconnect, pymongo.ConnectionFailure) as e:
107103
print(e)
108104
return False
109105

pytest-server-fixtures/pytest_server_fixtures/redis.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
import socket
99

1010
import pytest
11-
try:
12-
import redis
13-
except ImportError:
14-
pass
1511

1612
from pytest_server_fixtures import CONFIG
1713
from pytest_fixture_config import requires_config
@@ -33,19 +29,19 @@ def _redis_server(request):
3329
@pytest.fixture(scope='function')
3430
def redis_server(request):
3531
""" Function-scoped Redis server in a local thread.
36-
32+
3733
Attributes
3834
----------
39-
api: (``redis.Redis``) Redis client API connected to this server
40-
.. also inherits all attributes from the `workspace` fixture
35+
api: (``redis.Redis``) Redis client API connected to this server
36+
.. also inherits all attributes from the `workspace` fixture
4137
"""
4238
return _redis_server(request)
4339

4440

4541
@requires_config(CONFIG, ['redis_executable'])
4642
@pytest.fixture(scope='session')
4743
def redis_server_sess(request):
48-
""" Same as redis_server fixture, scoped for test session
44+
""" Same as redis_server fixture, scoped for test session
4945
"""
5046
return _redis_server(request)
5147

@@ -57,6 +53,8 @@ class RedisTestServer(TestServer):
5753
port_seed = 65532
5854

5955
def __init__(self, db=0, **kwargs):
56+
global redis
57+
import redis
6058
self.db = db
6159
super(RedisTestServer, self).__init__(**kwargs)
6260
self.api = redis.Redis(host=self.hostname, port=self.port, db=self.db)

0 commit comments

Comments
 (0)