##// END OF EJS Templates
pytest: use consistent way of creating a fixture by using pytest.fixture()
marcink -
r3946:39fb0295 default
parent child Browse files
Show More
@@ -25,7 +25,7 b' from rhodecode.model.scm import ScmModel'
25 from rhodecode.api.tests.utils import build_data, api_call, assert_ok
25 from rhodecode.api.tests.utils import build_data, api_call, assert_ok
26
26
27
27
28 @pytest.fixture
28 @pytest.fixture()
29 def http_host_stub():
29 def http_host_stub():
30 """
30 """
31 To ensure that we can get an IP address, this test shall run with a
31 To ensure that we can get an IP address, this test shall run with a
@@ -412,14 +412,14 b' class TestAdminSettingsVcs(object):'
412 setting = SettingsModel().get_setting_by_name(setting_key)
412 setting = SettingsModel().get_setting_by_name(setting_key)
413 assert setting.app_settings_value is new_value
413 assert setting.app_settings_value is new_value
414
414
415 @pytest.fixture
415 @pytest.fixture()
416 def disable_sql_cache(self, request):
416 def disable_sql_cache(self, request):
417 patcher = mock.patch(
417 patcher = mock.patch(
418 'rhodecode.lib.caching_query.FromCache.process_query')
418 'rhodecode.lib.caching_query.FromCache.process_query')
419 request.addfinalizer(patcher.stop)
419 request.addfinalizer(patcher.stop)
420 patcher.start()
420 patcher.start()
421
421
422 @pytest.fixture
422 @pytest.fixture()
423 def form_defaults(self):
423 def form_defaults(self):
424 from rhodecode.apps.admin.views.settings import AdminSettingsView
424 from rhodecode.apps.admin.views.settings import AdminSettingsView
425 return AdminSettingsView._form_defaults()
425 return AdminSettingsView._form_defaults()
@@ -83,7 +83,7 b' class GistUtility(object):'
83 Session().commit()
83 Session().commit()
84
84
85
85
86 @pytest.fixture
86 @pytest.fixture()
87 def create_gist(request):
87 def create_gist(request):
88 gist_utility = GistUtility()
88 gist_utility = GistUtility()
89 request.addfinalizer(gist_utility.cleanup)
89 request.addfinalizer(gist_utility.cleanup)
@@ -327,7 +327,7 b' def summary_view(context_stub, request_s'
327 @pytest.mark.usefixtures('app')
327 @pytest.mark.usefixtures('app')
328 class TestCreateReferenceData(object):
328 class TestCreateReferenceData(object):
329
329
330 @pytest.fixture
330 @pytest.fixture()
331 def example_refs(self):
331 def example_refs(self):
332 section_1_refs = OrderedDict((('a', 'a_id'), ('b', 'b_id')))
332 section_1_refs = OrderedDict((('a', 'a_id'), ('b', 'b_id')))
333 example_refs = [
333 example_refs = [
@@ -26,7 +26,7 b' from rhodecode.apps.ssh_support.lib.ssh_'
26 from rhodecode.lib.utils2 import AttributeDict
26 from rhodecode.lib.utils2 import AttributeDict
27
27
28
28
29 @pytest.fixture
29 @pytest.fixture()
30 def dummy_conf_file(tmpdir):
30 def dummy_conf_file(tmpdir):
31 conf = configparser.ConfigParser()
31 conf = configparser.ConfigParser()
32 conf.add_section('app:main')
32 conf.add_section('app:main')
@@ -48,7 +48,7 b' def plain_dummy_env():'
48 }
48 }
49
49
50
50
51 @pytest.fixture
51 @pytest.fixture()
52 def dummy_env():
52 def dummy_env():
53 return plain_dummy_env()
53 return plain_dummy_env()
54
54
@@ -57,12 +57,12 b' def plain_dummy_user():'
57 return AttributeDict(username='test_user')
57 return AttributeDict(username='test_user')
58
58
59
59
60 @pytest.fixture
60 @pytest.fixture()
61 def dummy_user():
61 def dummy_user():
62 return plain_dummy_user()
62 return plain_dummy_user()
63
63
64
64
65 @pytest.fixture
65 @pytest.fixture()
66 def ssh_wrapper(app, dummy_conf_file, dummy_env):
66 def ssh_wrapper(app, dummy_conf_file, dummy_env):
67 conn_info = '127.0.0.1 22 10.0.0.1 443'
67 conn_info = '127.0.0.1 22 10.0.0.1 443'
68 return SshWrapper(
68 return SshWrapper(
@@ -63,7 +63,7 b' class GitServerCreator(object):'
63 return server
63 return server
64
64
65
65
66 @pytest.fixture
66 @pytest.fixture()
67 def git_server(app):
67 def git_server(app):
68 return GitServerCreator()
68 return GitServerCreator()
69
69
@@ -62,7 +62,7 b' class MercurialServerCreator(object):'
62 return server
62 return server
63
63
64
64
65 @pytest.fixture
65 @pytest.fixture()
66 def hg_server(app):
66 def hg_server(app):
67 return MercurialServerCreator()
67 return MercurialServerCreator()
68
68
@@ -61,7 +61,7 b' class SubversionServerCreator(object):'
61 return server
61 return server
62
62
63
63
64 @pytest.fixture
64 @pytest.fixture()
65 def svn_server(app):
65 def svn_server(app):
66 return SubversionServerCreator()
66 return SubversionServerCreator()
67
67
@@ -32,7 +32,6 b' Please keep the following principles in '
32 """
32 """
33
33
34
34
35
36 def inspect_getargspec():
35 def inspect_getargspec():
37 """
36 """
38 Pyramid rely on inspect.getargspec to lookup the signature of
37 Pyramid rely on inspect.getargspec to lookup the signature of
@@ -25,7 +25,7 b' import pytest'
25 from rhodecode.config import environment
25 from rhodecode.config import environment
26
26
27
27
28 @pytest.fixture
28 @pytest.fixture()
29 def _external_calls_patcher(request):
29 def _external_calls_patcher(request):
30 # TODO: mikhail: This is a temporary solution. Ideally load_environment
30 # TODO: mikhail: This is a temporary solution. Ideally load_environment
31 # should be split into multiple small testable functions.
31 # should be split into multiple small testable functions.
@@ -59,7 +59,7 b' def pytest_collection_modifyitems(sessio'
59 items[:] = remaining
59 items[:] = remaining
60
60
61
61
62 @pytest.fixture
62 @pytest.fixture()
63 def db_backend(
63 def db_backend(
64 request, db_backend_name, ini_config, tmpdir_factory):
64 request, db_backend_name, ini_config, tmpdir_factory):
65 basetemp = tmpdir_factory.getbasetemp().strpath
65 basetemp = tmpdir_factory.getbasetemp().strpath
@@ -32,7 +32,7 b' from rhodecode.events.repo import ('
32 )
32 )
33
33
34
34
35 @pytest.fixture
35 @pytest.fixture()
36 def scm_extras(user_regular, repo_stub):
36 def scm_extras(user_regular, repo_stub):
37 extras = utils2.AttributeDict({
37 extras = utils2.AttributeDict({
38 'ip': '127.0.0.1',
38 'ip': '127.0.0.1',
@@ -24,7 +24,7 b' from rhodecode import events'
24 from rhodecode.lib.utils2 import AttributeDict
24 from rhodecode.lib.utils2 import AttributeDict
25
25
26
26
27 @pytest.fixture
27 @pytest.fixture()
28 def repo_push_event(backend, user_regular):
28 def repo_push_event(backend, user_regular):
29 commits = [
29 commits = [
30 {'message': 'ancestor commit fixes #15'},
30 {'message': 'ancestor commit fixes #15'},
@@ -47,7 +47,7 b' class TestDeleteScopesDeletesIntegration'
47 assert integration is None
47 assert integration is None
48
48
49
49
50 @pytest.fixture
50 @pytest.fixture()
51 def integration_repos(request, StubIntegrationType, stub_integration_settings):
51 def integration_repos(request, StubIntegrationType, stub_integration_settings):
52 """
52 """
53 Create repositories and integrations for testing, and destroy them after
53 Create repositories and integrations for testing, and destroy them after
@@ -26,7 +26,7 b' from rhodecode.model.db import Session, '
26 from rhodecode.integrations.types.slack import SlackIntegrationType
26 from rhodecode.integrations.types.slack import SlackIntegrationType
27
27
28
28
29 @pytest.fixture
29 @pytest.fixture()
30 def slack_settings():
30 def slack_settings():
31 return {
31 return {
32 "service": "mock://slackintegration",
32 "service": "mock://slackintegration",
@@ -40,7 +40,7 b' def slack_settings():'
40 }
40 }
41
41
42
42
43 @pytest.fixture
43 @pytest.fixture()
44 def slack_integration(request, app, slack_settings):
44 def slack_integration(request, app, slack_settings):
45 integration = Integration()
45 integration = Integration()
46 integration.name = 'test slack integration'
46 integration.name = 'test slack integration'
@@ -25,7 +25,7 b' from rhodecode.lib.utils2 import Attribu'
25 from rhodecode.integrations.types.webhook import WebhookDataHandler
25 from rhodecode.integrations.types.webhook import WebhookDataHandler
26
26
27
27
28 @pytest.fixture
28 @pytest.fixture()
29 def base_data():
29 def base_data():
30 return {
30 return {
31 'name': 'event',
31 'name': 'event',
@@ -77,7 +77,7 b' def test_authenticate_migrates_to_new_ha'
77 assert result == stub_auth_data
77 assert result == stub_auth_data
78
78
79
79
80 @pytest.fixture
80 @pytest.fixture()
81 def stub_auth_data(user_util):
81 def stub_auth_data(user_util):
82 user = user_util.create_user()
82 user = user_util.create_user()
83 data = {
83 data = {
@@ -73,7 +73,7 b' class StubVCSController(simplevcs.Simple'
73 return None
73 return None
74
74
75
75
76 @pytest.fixture
76 @pytest.fixture()
77 def vcscontroller(baseapp, config_stub, request_stub):
77 def vcscontroller(baseapp, config_stub, request_stub):
78 config_stub.testing_securitypolicy()
78 config_stub.testing_securitypolicy()
79 config_stub.include('rhodecode.authentication')
79 config_stub.include('rhodecode.authentication')
@@ -40,7 +40,7 b' def test_does_chunked_end_to_end_transfe'
40 assert times[1] - times[0] > 0.1, "Chunks arrived at the same time"
40 assert times[1] - times[0] > 0.1, "Chunks arrived at the same time"
41
41
42
42
43 @pytest.fixture
43 @pytest.fixture()
44 def echo_app_chunking(request, available_port_factory):
44 def echo_app_chunking(request, available_port_factory):
45 """
45 """
46 Run the EchoApp via Waitress in a subprocess.
46 Run the EchoApp via Waitress in a subprocess.
@@ -63,7 +63,7 b' def echo_app_chunking(request, available'
63 return echo_app_url
63 return echo_app_url
64
64
65
65
66 @pytest.fixture
66 @pytest.fixture()
67 def scm_app(request, available_port_factory, echo_app_chunking):
67 def scm_app(request, available_port_factory, echo_app_chunking):
68 """
68 """
69 Run the scm_app in Waitress.
69 Run the scm_app in Waitress.
@@ -86,12 +86,12 b' def crypto_backend_class(request):'
86 return request.param
86 return request.param
87
87
88
88
89 @pytest.fixture
89 @pytest.fixture()
90 def crypto_backend(crypto_backend_class):
90 def crypto_backend(crypto_backend_class):
91 return crypto_backend_class()
91 return crypto_backend_class()
92
92
93
93
94 @pytest.fixture
94 @pytest.fixture()
95 def password():
95 def password():
96 encoding = 'utf-8'
96 encoding = 'utf-8'
97 value = u'value'
97 value = u'value'
@@ -25,7 +25,7 b' from rhodecode.lib.db_manage import DbMa'
25 from rhodecode.model import db
25 from rhodecode.model import db
26
26
27
27
28 @pytest.fixture
28 @pytest.fixture()
29 def db_manage(baseapp):
29 def db_manage(baseapp):
30 db_manage = DbManage(
30 db_manage = DbManage(
31 log_sql=True, dbconf='fake', root='fake', tests=False,
31 log_sql=True, dbconf='fake', root='fake', tests=False,
@@ -173,7 +173,7 b' class TestMixedFilenameEncodings(object)'
173 return fixture.load_resource(
173 return fixture.load_resource(
174 'hg_diff_mixed_filename_encodings.diff')
174 'hg_diff_mixed_filename_encodings.diff')
175
175
176 @pytest.fixture
176 @pytest.fixture()
177 def processor(self, raw_diff):
177 def processor(self, raw_diff):
178 diff = MercurialDiff(raw_diff)
178 diff = MercurialDiff(raw_diff)
179 processor = DiffProcessor(diff)
179 processor = DiffProcessor(diff)
@@ -238,7 +238,7 b' def test_find_context_end_of_chunk(diff_'
238 assert found_line == [diffs.DiffLineNumber(old=13, new=14)]
238 assert found_line == [diffs.DiffLineNumber(old=13, new=14)]
239
239
240
240
241 @pytest.fixture
241 @pytest.fixture()
242 def diff_processor(request, diff_fixture):
242 def diff_processor(request, diff_fixture):
243 raw_diff = diffs_store[diff_fixture]
243 raw_diff = diffs_store[diff_fixture]
244 diff = GitDiff(raw_diff)
244 diff = GitDiff(raw_diff)
@@ -247,7 +247,7 b' def diff_processor(request, diff_fixture'
247 return processor
247 return processor
248
248
249
249
250 @pytest.fixture
250 @pytest.fixture()
251 def diff_fixture():
251 def diff_fixture():
252 return 'default.diff'
252 return 'default.diff'
253
253
@@ -61,7 +61,7 b' def assert_called_with_mock(callable_, e'
61 assert mock_name == expected_mock_name
61 assert mock_name == expected_mock_name
62
62
63
63
64 @pytest.fixture
64 @pytest.fixture()
65 def hook_extras(user_regular, repo_stub):
65 def hook_extras(user_regular, repo_stub):
66 extras = utils2.AttributeDict({
66 extras = utils2.AttributeDict({
67 'ip': '127.0.0.1',
67 'ip': '127.0.0.1',
@@ -325,7 +325,7 b' class MockServer(object):'
325 self.handler = Handler(self.request, ip_port, self)
325 self.handler = Handler(self.request, ip_port, self)
326
326
327
327
328 @pytest.fixture
328 @pytest.fixture()
329 def tcp_server():
329 def tcp_server():
330 server = mock.Mock()
330 server = mock.Mock()
331 server.server_address = ('127.0.0.1', 8881)
331 server.server_address = ('127.0.0.1', 8881)
@@ -29,12 +29,12 b' from rhodecode.lib.jsonalchemy import ('
29 MutationDict, MutationList, MutationObj, JsonType)
29 MutationDict, MutationList, MutationObj, JsonType)
30
30
31
31
32 @pytest.fixture
32 @pytest.fixture()
33 def engine():
33 def engine():
34 return create_engine('sqlite://')
34 return create_engine('sqlite://')
35
35
36
36
37 @pytest.fixture
37 @pytest.fixture()
38 def session(engine):
38 def session(engine):
39 return sessionmaker(bind=engine)()
39 return sessionmaker(bind=engine)()
40
40
@@ -797,7 +797,7 b' class TestDefaultRepoSettings(object):'
797 assert result[setting] == 'value'
797 assert result[setting] == 'value'
798
798
799
799
800 @pytest.fixture
800 @pytest.fixture()
801 def fake_ui_values():
801 def fake_ui_values():
802 return [
802 return [
803 UiSetting(
803 UiSetting(
@@ -36,7 +36,7 b' from rhodecode.tests.fixture import Fixt'
36 fixture = Fixture()
36 fixture = Fixture()
37
37
38
38
39 @pytest.fixture
39 @pytest.fixture()
40 def repo_name(backend_hg):
40 def repo_name(backend_hg):
41 return backend_hg.repo_name
41 return backend_hg.repo_name
42
42
@@ -44,7 +44,7 b' pytestmark = ['
44 @pytest.mark.usefixtures('config_stub')
44 @pytest.mark.usefixtures('config_stub')
45 class TestPullRequestModel(object):
45 class TestPullRequestModel(object):
46
46
47 @pytest.fixture
47 @pytest.fixture()
48 def pull_request(self, request, backend, pr_util):
48 def pull_request(self, request, backend, pr_util):
49 """
49 """
50 A pull request combined with multiples patches.
50 A pull request combined with multiples patches.
@@ -538,7 +538,7 b' def test_merge_response_message(mr_type,'
538 assert merge_response.merge_status_message == expected_msg
538 assert merge_response.merge_status_message == expected_msg
539
539
540
540
541 @pytest.fixture
541 @pytest.fixture()
542 def merge_extras(user_regular):
542 def merge_extras(user_regular):
543 """
543 """
544 Context for the vcs operation when running a merge.
544 Context for the vcs operation when running a merge.
@@ -24,7 +24,7 b' from rhodecode.lib.vcs import nodes'
24 from rhodecode.model.repo import ReadmeFinder
24 from rhodecode.model.repo import ReadmeFinder
25
25
26
26
27 @pytest.fixture
27 @pytest.fixture()
28 def commit_util(vcsbackend_stub):
28 def commit_util(vcsbackend_stub):
29 """
29 """
30 Provide a commit which has certain files in it's tree.
30 Provide a commit which has certain files in it's tree.
@@ -119,7 +119,7 b' class TestGetUsers(object):'
119 assert len(fake_users) == 3
119 assert len(fake_users) == 3
120
120
121
121
122 @pytest.fixture
122 @pytest.fixture()
123 def test_user(request, baseapp):
123 def test_user(request, baseapp):
124 usr = UserModel().create_or_update(
124 usr = UserModel().create_or_update(
125 username=u'test_user',
125 username=u'test_user',
@@ -40,7 +40,7 b' fixture = Fixture()'
40 pytestmark = pytest.mark.usefixtures('baseapp')
40 pytestmark = pytest.mark.usefixtures('baseapp')
41
41
42
42
43 @pytest.fixture
43 @pytest.fixture()
44 def localizer():
44 def localizer():
45 def func(msg):
45 def func(msg):
46 return msg
46 return msg
@@ -164,7 +164,7 b' def activate_example_rcextensions(reques'
164 rhodecode.EXTENSIONS = old_extensions
164 rhodecode.EXTENSIONS = old_extensions
165
165
166
166
167 @pytest.fixture
167 @pytest.fixture()
168 def capture_rcextensions():
168 def capture_rcextensions():
169 """
169 """
170 Returns the recorded calls to entry points in rcextensions.
170 Returns the recorded calls to entry points in rcextensions.
@@ -192,7 +192,7 b' def plain_http_host_stub():'
192 return 'example.com:80'
192 return 'example.com:80'
193
193
194
194
195 @pytest.fixture
195 @pytest.fixture()
196 def http_host_stub():
196 def http_host_stub():
197 """
197 """
198 Value of HTTP_HOST in the test run.
198 Value of HTTP_HOST in the test run.
@@ -207,7 +207,7 b' def plain_http_host_only_stub():'
207 return plain_http_host_stub().split(':')[0]
207 return plain_http_host_stub().split(':')[0]
208
208
209
209
210 @pytest.fixture
210 @pytest.fixture()
211 def http_host_only_stub():
211 def http_host_only_stub():
212 """
212 """
213 Value of HTTP_HOST in the test run.
213 Value of HTTP_HOST in the test run.
@@ -232,7 +232,7 b' def plain_http_environ():'
232 }
232 }
233
233
234
234
235 @pytest.fixture
235 @pytest.fixture()
236 def http_environ():
236 def http_environ():
237 """
237 """
238 HTTP extra environ keys.
238 HTTP extra environ keys.
@@ -294,7 +294,7 b' def _autologin_user(app, *args):'
294 return LoginData(csrf_token, session['rhodecode_user'])
294 return LoginData(csrf_token, session['rhodecode_user'])
295
295
296
296
297 @pytest.fixture
297 @pytest.fixture()
298 def autologin_user(app):
298 def autologin_user(app):
299 """
299 """
300 Utility fixture which makes sure that the admin user is logged in
300 Utility fixture which makes sure that the admin user is logged in
@@ -302,7 +302,7 b' def autologin_user(app):'
302 return _autologin_user(app)
302 return _autologin_user(app)
303
303
304
304
305 @pytest.fixture
305 @pytest.fixture()
306 def autologin_regular_user(app):
306 def autologin_regular_user(app):
307 """
307 """
308 Utility fixture which makes sure that the regular user is logged in
308 Utility fixture which makes sure that the regular user is logged in
@@ -321,7 +321,7 b' def xhr_header(request):'
321 return {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'}
321 return {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'}
322
322
323
323
324 @pytest.fixture
324 @pytest.fixture()
325 def real_crypto_backend(monkeypatch):
325 def real_crypto_backend(monkeypatch):
326 """
326 """
327 Switch the production crypto backend on for this test.
327 Switch the production crypto backend on for this test.
@@ -356,7 +356,7 b' def tests_tmp_path(request):'
356 return TESTS_TMP_PATH
356 return TESTS_TMP_PATH
357
357
358
358
359 @pytest.fixture
359 @pytest.fixture()
360 def test_repo_group(request):
360 def test_repo_group(request):
361 """
361 """
362 Create a temporary repository group, and destroy it after
362 Create a temporary repository group, and destroy it after
@@ -373,7 +373,7 b' def test_repo_group(request):'
373 return repo_group
373 return repo_group
374
374
375
375
376 @pytest.fixture
376 @pytest.fixture()
377 def test_user_group(request):
377 def test_user_group(request):
378 """
378 """
379 Create a temporary user group, and destroy it after
379 Create a temporary user group, and destroy it after
@@ -464,7 +464,7 b' def backend_base(request, backend_alias,'
464 return backend
464 return backend
465
465
466
466
467 @pytest.fixture
467 @pytest.fixture()
468 def backend(request, backend_alias, baseapp, test_repo):
468 def backend(request, backend_alias, baseapp, test_repo):
469 """
469 """
470 Parametrized fixture which represents a single backend implementation.
470 Parametrized fixture which represents a single backend implementation.
@@ -479,22 +479,22 b' def backend(request, backend_alias, base'
479 return backend_base(request, backend_alias, baseapp, test_repo)
479 return backend_base(request, backend_alias, baseapp, test_repo)
480
480
481
481
482 @pytest.fixture
482 @pytest.fixture()
483 def backend_git(request, baseapp, test_repo):
483 def backend_git(request, baseapp, test_repo):
484 return backend_base(request, 'git', baseapp, test_repo)
484 return backend_base(request, 'git', baseapp, test_repo)
485
485
486
486
487 @pytest.fixture
487 @pytest.fixture()
488 def backend_hg(request, baseapp, test_repo):
488 def backend_hg(request, baseapp, test_repo):
489 return backend_base(request, 'hg', baseapp, test_repo)
489 return backend_base(request, 'hg', baseapp, test_repo)
490
490
491
491
492 @pytest.fixture
492 @pytest.fixture()
493 def backend_svn(request, baseapp, test_repo):
493 def backend_svn(request, baseapp, test_repo):
494 return backend_base(request, 'svn', baseapp, test_repo)
494 return backend_base(request, 'svn', baseapp, test_repo)
495
495
496
496
497 @pytest.fixture
497 @pytest.fixture()
498 def backend_random(backend_git):
498 def backend_random(backend_git):
499 """
499 """
500 Use this to express that your tests need "a backend.
500 Use this to express that your tests need "a backend.
@@ -511,7 +511,7 b' def backend_random(backend_git):'
511 return backend_git
511 return backend_git
512
512
513
513
514 @pytest.fixture
514 @pytest.fixture()
515 def backend_stub(backend_git):
515 def backend_stub(backend_git):
516 """
516 """
517 Use this to express that your tests need a backend stub
517 Use this to express that your tests need a backend stub
@@ -522,7 +522,7 b' def backend_stub(backend_git):'
522 return backend_git
522 return backend_git
523
523
524
524
525 @pytest.fixture
525 @pytest.fixture()
526 def repo_stub(backend_stub):
526 def repo_stub(backend_stub):
527 """
527 """
528 Use this to express that your tests need a repository stub
528 Use this to express that your tests need a repository stub
@@ -722,7 +722,7 b' def vcsbackend_base(request, backend_ali'
722 return backend
722 return backend
723
723
724
724
725 @pytest.fixture
725 @pytest.fixture()
726 def vcsbackend(request, backend_alias, tests_tmp_path, baseapp, test_repo):
726 def vcsbackend(request, backend_alias, tests_tmp_path, baseapp, test_repo):
727 """
727 """
728 Parametrized fixture which represents a single vcs backend implementation.
728 Parametrized fixture which represents a single vcs backend implementation.
@@ -736,22 +736,22 b' def vcsbackend(request, backend_alias, t'
736 return vcsbackend_base(request, backend_alias, tests_tmp_path, baseapp, test_repo)
736 return vcsbackend_base(request, backend_alias, tests_tmp_path, baseapp, test_repo)
737
737
738
738
739 @pytest.fixture
739 @pytest.fixture()
740 def vcsbackend_git(request, tests_tmp_path, baseapp, test_repo):
740 def vcsbackend_git(request, tests_tmp_path, baseapp, test_repo):
741 return vcsbackend_base(request, 'git', tests_tmp_path, baseapp, test_repo)
741 return vcsbackend_base(request, 'git', tests_tmp_path, baseapp, test_repo)
742
742
743
743
744 @pytest.fixture
744 @pytest.fixture()
745 def vcsbackend_hg(request, tests_tmp_path, baseapp, test_repo):
745 def vcsbackend_hg(request, tests_tmp_path, baseapp, test_repo):
746 return vcsbackend_base(request, 'hg', tests_tmp_path, baseapp, test_repo)
746 return vcsbackend_base(request, 'hg', tests_tmp_path, baseapp, test_repo)
747
747
748
748
749 @pytest.fixture
749 @pytest.fixture()
750 def vcsbackend_svn(request, tests_tmp_path, baseapp, test_repo):
750 def vcsbackend_svn(request, tests_tmp_path, baseapp, test_repo):
751 return vcsbackend_base(request, 'svn', tests_tmp_path, baseapp, test_repo)
751 return vcsbackend_base(request, 'svn', tests_tmp_path, baseapp, test_repo)
752
752
753
753
754 @pytest.fixture
754 @pytest.fixture()
755 def vcsbackend_stub(vcsbackend_git):
755 def vcsbackend_stub(vcsbackend_git):
756 """
756 """
757 Use this to express that your test just needs a stub of a vcsbackend.
757 Use this to express that your test just needs a stub of a vcsbackend.
@@ -878,7 +878,7 b' def _add_commits_to_repo(vcs_repo, commi'
878 return commit_ids
878 return commit_ids
879
879
880
880
881 @pytest.fixture
881 @pytest.fixture()
882 def reposerver(request):
882 def reposerver(request):
883 """
883 """
884 Allows to serve a backend repository
884 Allows to serve a backend repository
@@ -916,7 +916,7 b' class RepoServer(object):'
916 proc.terminate()
916 proc.terminate()
917
917
918
918
919 @pytest.fixture
919 @pytest.fixture()
920 def pr_util(backend, request, config_stub):
920 def pr_util(backend, request, config_stub):
921 """
921 """
922 Utility for tests of models and for functional tests around pull requests.
922 Utility for tests of models and for functional tests around pull requests.
@@ -1117,7 +1117,7 b' class PRTestUtility(object):'
1117 self.mergeable_patcher.stop()
1117 self.mergeable_patcher.stop()
1118
1118
1119
1119
1120 @pytest.fixture
1120 @pytest.fixture()
1121 def user_admin(baseapp):
1121 def user_admin(baseapp):
1122 """
1122 """
1123 Provides the default admin test user as an instance of `db.User`.
1123 Provides the default admin test user as an instance of `db.User`.
@@ -1126,7 +1126,7 b' def user_admin(baseapp):'
1126 return user
1126 return user
1127
1127
1128
1128
1129 @pytest.fixture
1129 @pytest.fixture()
1130 def user_regular(baseapp):
1130 def user_regular(baseapp):
1131 """
1131 """
1132 Provides the default regular test user as an instance of `db.User`.
1132 Provides the default regular test user as an instance of `db.User`.
@@ -1135,7 +1135,7 b' def user_regular(baseapp):'
1135 return user
1135 return user
1136
1136
1137
1137
1138 @pytest.fixture
1138 @pytest.fixture()
1139 def user_util(request, db_connection):
1139 def user_util(request, db_connection):
1140 """
1140 """
1141 Provides a wired instance of `UserUtility` with integrated cleanup.
1141 Provides a wired instance of `UserUtility` with integrated cleanup.
@@ -1468,7 +1468,7 b' class AppenlightClient(object):'
1468 raise Exception('Sending to appenlight failed')
1468 raise Exception('Sending to appenlight failed')
1469
1469
1470
1470
1471 @pytest.fixture
1471 @pytest.fixture()
1472 def gist_util(request, db_connection):
1472 def gist_util(request, db_connection):
1473 """
1473 """
1474 Provides a wired instance of `GistUtility` with integrated cleanup.
1474 Provides a wired instance of `GistUtility` with integrated cleanup.
@@ -1493,13 +1493,13 b' class GistUtility(object):'
1493 self.fixture.destroy_gists(str(id_))
1493 self.fixture.destroy_gists(str(id_))
1494
1494
1495
1495
1496 @pytest.fixture
1496 @pytest.fixture()
1497 def enabled_backends(request):
1497 def enabled_backends(request):
1498 backends = request.config.option.backends
1498 backends = request.config.option.backends
1499 return backends[:]
1499 return backends[:]
1500
1500
1501
1501
1502 @pytest.fixture
1502 @pytest.fixture()
1503 def settings_util(request, db_connection):
1503 def settings_util(request, db_connection):
1504 """
1504 """
1505 Provides a wired instance of `SettingsUtility` with integrated cleanup.
1505 Provides a wired instance of `SettingsUtility` with integrated cleanup.
@@ -1591,7 +1591,7 b' class SettingsUtility(object):'
1591 Session().commit()
1591 Session().commit()
1592
1592
1593
1593
1594 @pytest.fixture
1594 @pytest.fixture()
1595 def no_notifications(request):
1595 def no_notifications(request):
1596 notification_patcher = mock.patch(
1596 notification_patcher = mock.patch(
1597 'rhodecode.model.notification.NotificationModel.create')
1597 'rhodecode.model.notification.NotificationModel.create')
@@ -1610,12 +1610,12 b' def repeat(request):'
1610 return request.config.getoption('--repeat')
1610 return request.config.getoption('--repeat')
1611
1611
1612
1612
1613 @pytest.fixture
1613 @pytest.fixture()
1614 def rhodecode_fixtures():
1614 def rhodecode_fixtures():
1615 return Fixture()
1615 return Fixture()
1616
1616
1617
1617
1618 @pytest.fixture
1618 @pytest.fixture()
1619 def context_stub():
1619 def context_stub():
1620 """
1620 """
1621 Stub context object.
1621 Stub context object.
@@ -1624,7 +1624,7 b' def context_stub():'
1624 return context
1624 return context
1625
1625
1626
1626
1627 @pytest.fixture
1627 @pytest.fixture()
1628 def request_stub():
1628 def request_stub():
1629 """
1629 """
1630 Stub request object.
1630 Stub request object.
@@ -1634,7 +1634,7 b' def request_stub():'
1634 return request
1634 return request
1635
1635
1636
1636
1637 @pytest.fixture
1637 @pytest.fixture()
1638 def config_stub(request, request_stub):
1638 def config_stub(request, request_stub):
1639 """
1639 """
1640 Set up pyramid.testing and return the Configurator.
1640 Set up pyramid.testing and return the Configurator.
@@ -1649,7 +1649,7 b' def config_stub(request, request_stub):'
1649 return config
1649 return config
1650
1650
1651
1651
1652 @pytest.fixture
1652 @pytest.fixture()
1653 def StubIntegrationType():
1653 def StubIntegrationType():
1654 class _StubIntegrationType(IntegrationTypeBase):
1654 class _StubIntegrationType(IntegrationTypeBase):
1655 """ Test integration type class """
1655 """ Test integration type class """
@@ -1686,7 +1686,7 b' def StubIntegrationType():'
1686 integration_type_registry.register_integration_type(_StubIntegrationType)
1686 integration_type_registry.register_integration_type(_StubIntegrationType)
1687 return _StubIntegrationType
1687 return _StubIntegrationType
1688
1688
1689 @pytest.fixture
1689 @pytest.fixture()
1690 def stub_integration_settings():
1690 def stub_integration_settings():
1691 return {
1691 return {
1692 'test_string_field': 'some data',
1692 'test_string_field': 'some data',
@@ -1694,7 +1694,7 b' def stub_integration_settings():'
1694 }
1694 }
1695
1695
1696
1696
1697 @pytest.fixture
1697 @pytest.fixture()
1698 def repo_integration_stub(request, repo_stub, StubIntegrationType,
1698 def repo_integration_stub(request, repo_stub, StubIntegrationType,
1699 stub_integration_settings):
1699 stub_integration_settings):
1700 integration = IntegrationModel().create(
1700 integration = IntegrationModel().create(
@@ -1709,7 +1709,7 b' def repo_integration_stub(request, repo_'
1709 return integration
1709 return integration
1710
1710
1711
1711
1712 @pytest.fixture
1712 @pytest.fixture()
1713 def repogroup_integration_stub(request, test_repo_group, StubIntegrationType,
1713 def repogroup_integration_stub(request, test_repo_group, StubIntegrationType,
1714 stub_integration_settings):
1714 stub_integration_settings):
1715 integration = IntegrationModel().create(
1715 integration = IntegrationModel().create(
@@ -1724,7 +1724,7 b' def repogroup_integration_stub(request, '
1724 return integration
1724 return integration
1725
1725
1726
1726
1727 @pytest.fixture
1727 @pytest.fixture()
1728 def repogroup_recursive_integration_stub(request, test_repo_group,
1728 def repogroup_recursive_integration_stub(request, test_repo_group,
1729 StubIntegrationType, stub_integration_settings):
1729 StubIntegrationType, stub_integration_settings):
1730 integration = IntegrationModel().create(
1730 integration = IntegrationModel().create(
@@ -1739,7 +1739,7 b' def repogroup_recursive_integration_stub'
1739 return integration
1739 return integration
1740
1740
1741
1741
1742 @pytest.fixture
1742 @pytest.fixture()
1743 def global_integration_stub(request, StubIntegrationType,
1743 def global_integration_stub(request, StubIntegrationType,
1744 stub_integration_settings):
1744 stub_integration_settings):
1745 integration = IntegrationModel().create(
1745 integration = IntegrationModel().create(
@@ -1754,7 +1754,7 b' def global_integration_stub(request, Stu'
1754 return integration
1754 return integration
1755
1755
1756
1756
1757 @pytest.fixture
1757 @pytest.fixture()
1758 def root_repos_integration_stub(request, StubIntegrationType,
1758 def root_repos_integration_stub(request, StubIntegrationType,
1759 stub_integration_settings):
1759 stub_integration_settings):
1760 integration = IntegrationModel().create(
1760 integration = IntegrationModel().create(
@@ -1769,7 +1769,7 b' def root_repos_integration_stub(request,'
1769 return integration
1769 return integration
1770
1770
1771
1771
1772 @pytest.fixture
1772 @pytest.fixture()
1773 def local_dt_to_utc():
1773 def local_dt_to_utc():
1774 def _factory(dt):
1774 def _factory(dt):
1775 return dt.replace(tzinfo=dateutil.tz.tzlocal()).astimezone(
1775 return dt.replace(tzinfo=dateutil.tz.tzlocal()).astimezone(
@@ -1777,7 +1777,7 b' def local_dt_to_utc():'
1777 return _factory
1777 return _factory
1778
1778
1779
1779
1780 @pytest.fixture
1780 @pytest.fixture()
1781 def disable_anonymous_user(request, baseapp):
1781 def disable_anonymous_user(request, baseapp):
1782 set_anonymous_access(False)
1782 set_anonymous_access(False)
1783
1783
@@ -1791,7 +1791,7 b' def rc_fixture(request):'
1791 return Fixture()
1791 return Fixture()
1792
1792
1793
1793
1794 @pytest.fixture
1794 @pytest.fixture()
1795 def repo_groups(request):
1795 def repo_groups(request):
1796 fixture = Fixture()
1796 fixture = Fixture()
1797
1797
@@ -235,7 +235,7 b' def available_port_factory():'
235 return get_available_port
235 return get_available_port
236
236
237
237
238 @pytest.fixture
238 @pytest.fixture()
239 def available_port(available_port_factory):
239 def available_port(available_port_factory):
240 """
240 """
241 Gives you one free port for the current test.
241 Gives you one free port for the current test.
@@ -112,7 +112,7 b' def _create_empty_repository(cls, backen'
112 return repo
112 return repo
113
113
114
114
115 @pytest.fixture
115 @pytest.fixture()
116 def config():
116 def config():
117 """
117 """
118 Instance of a repository config.
118 Instance of a repository config.
@@ -151,7 +151,7 b' def _add_commits_to_repo(repo, commits):'
151 return tip
151 return tip
152
152
153
153
154 @pytest.fixture
154 @pytest.fixture()
155 def vcs_repo(request, backend_alias):
155 def vcs_repo(request, backend_alias):
156 Backend = get_backend(backend_alias)
156 Backend = get_backend(backend_alias)
157 repo_path = get_new_dir(str(time.time()))
157 repo_path = get_new_dir(str(time.time()))
@@ -164,7 +164,7 b' def vcs_repo(request, backend_alias):'
164 return repo
164 return repo
165
165
166
166
167 @pytest.fixture
167 @pytest.fixture()
168 def generate_repo_with_commits(vcs_repo):
168 def generate_repo_with_commits(vcs_repo):
169 """
169 """
170 Creates a fabric to generate N comits with some file nodes on a randomly
170 Creates a fabric to generate N comits with some file nodes on a randomly
@@ -194,7 +194,7 b' def generate_repo_with_commits(vcs_repo)'
194 return commit_maker
194 return commit_maker
195
195
196
196
197 @pytest.fixture
197 @pytest.fixture()
198 def hg_repo(request, vcs_repo):
198 def hg_repo(request, vcs_repo):
199 repo = vcs_repo
199 repo = vcs_repo
200
200
@@ -204,7 +204,7 b' def hg_repo(request, vcs_repo):'
204 return repo
204 return repo
205
205
206
206
207 @pytest.fixture
207 @pytest.fixture()
208 def hg_commit(hg_repo):
208 def hg_commit(hg_repo):
209 return hg_repo.get_commit()
209 return hg_repo.get_commit()
210
210
@@ -112,7 +112,7 b' class TestArchives(BackendTestMixin):'
112 self.tip.archive_repo(self.temp_file, kind='wrong kind')
112 self.tip.archive_repo(self.temp_file, kind='wrong kind')
113
113
114
114
115 @pytest.fixture
115 @pytest.fixture()
116 def base_commit():
116 def base_commit():
117 """
117 """
118 Prepare a `base.BaseCommit` just enough for `_validate_archive_prefix`.
118 Prepare a `base.BaseCommit` just enough for `_validate_archive_prefix`.
@@ -34,7 +34,7 b' def is_new_connection(logger, level, mes'
34 message.startswith('Starting new HTTP'))
34 message.startswith('Starting new HTTP'))
35
35
36
36
37 @pytest.fixture
37 @pytest.fixture()
38 def stub_session():
38 def stub_session():
39 """
39 """
40 Stub of `requests.Session()`.
40 Stub of `requests.Session()`.
@@ -48,7 +48,7 b' def stub_session():'
48 return session
48 return session
49
49
50
50
51 @pytest.fixture
51 @pytest.fixture()
52 def stub_fail_session():
52 def stub_fail_session():
53 """
53 """
54 Stub of `requests.Session()`.
54 Stub of `requests.Session()`.
@@ -62,7 +62,7 b' def stub_fail_session():'
62 return session
62 return session
63
63
64
64
65 @pytest.fixture
65 @pytest.fixture()
66 def stub_session_factory(stub_session):
66 def stub_session_factory(stub_session):
67 """
67 """
68 Stub of `rhodecode.lib.vcs.client_http.ThreadlocalSessionFactory`.
68 Stub of `rhodecode.lib.vcs.client_http.ThreadlocalSessionFactory`.
@@ -72,7 +72,7 b' def stub_session_factory(stub_session):'
72 return session_factory
72 return session_factory
73
73
74
74
75 @pytest.fixture
75 @pytest.fixture()
76 def stub_session_failing_factory(stub_fail_session):
76 def stub_session_failing_factory(stub_fail_session):
77 """
77 """
78 Stub of `rhodecode.lib.vcs.client_http.ThreadlocalSessionFactory`.
78 Stub of `rhodecode.lib.vcs.client_http.ThreadlocalSessionFactory`.
@@ -743,7 +743,7 b' TODO: To be written...'
743
743
744 class TestGetShadowInstance(object):
744 class TestGetShadowInstance(object):
745
745
746 @pytest.fixture
746 @pytest.fixture()
747 def repo(self, vcsbackend_hg, monkeypatch):
747 def repo(self, vcsbackend_hg, monkeypatch):
748 repo = vcsbackend_hg.repo
748 repo = vcsbackend_hg.repo
749 monkeypatch.setattr(repo, 'config', mock.Mock())
749 monkeypatch.setattr(repo, 'config', mock.Mock())
@@ -34,7 +34,7 b' from rhodecode.lib.vcs.nodes import DirN'
34 from rhodecode.tests.vcs.conftest import BackendTestMixin
34 from rhodecode.tests.vcs.conftest import BackendTestMixin
35
35
36
36
37 @pytest.fixture
37 @pytest.fixture()
38 def nodes():
38 def nodes():
39 nodes = [
39 nodes = [
40 FileNode('foobar', content='Foo & bar'),
40 FileNode('foobar', content='Foo & bar'),
@@ -35,13 +35,13 b' pytestmark = ['
35 ]
35 ]
36
36
37
37
38 @pytest.fixture
38 @pytest.fixture()
39 def repo(baseapp):
39 def repo(baseapp):
40 repo = SubversionRepository(os.path.join(TESTS_TMP_PATH, SVN_REPO))
40 repo = SubversionRepository(os.path.join(TESTS_TMP_PATH, SVN_REPO))
41 return repo
41 return repo
42
42
43
43
44 @pytest.fixture
44 @pytest.fixture()
45 def head(repo):
45 def head(repo):
46 return repo.get_commit()
46 return repo.get_commit()
47
47
@@ -155,7 +155,7 b' def rc_web_server('
155 return server
155 return server
156
156
157
157
158 @pytest.fixture
158 @pytest.fixture()
159 def disable_locking(baseapp):
159 def disable_locking(baseapp):
160 r = Repository.get_by_repo_name(GIT_REPO)
160 r = Repository.get_by_repo_name(GIT_REPO)
161 Repository.unlock(r)
161 Repository.unlock(r)
@@ -170,7 +170,7 b' def disable_locking(baseapp):'
170 Session().commit()
170 Session().commit()
171
171
172
172
173 @pytest.fixture
173 @pytest.fixture()
174 def enable_auth_plugins(request, baseapp, csrf_token):
174 def enable_auth_plugins(request, baseapp, csrf_token):
175 """
175 """
176 Return a factory object that when called, allows to control which
176 Return a factory object that when called, allows to control which
@@ -217,7 +217,7 b' def enable_auth_plugins(request, baseapp'
217 return _enable_plugins
217 return _enable_plugins
218
218
219
219
220 @pytest.fixture
220 @pytest.fixture()
221 def fs_repo_only(request, rhodecode_fixtures):
221 def fs_repo_only(request, rhodecode_fixtures):
222 def fs_repo_fabric(repo_name, repo_type):
222 def fs_repo_fabric(repo_name, repo_type):
223 rhodecode_fixtures.create_repo(repo_name, repo_type=repo_type)
223 rhodecode_fixtures.create_repo(repo_name, repo_type=repo_type)
@@ -232,7 +232,7 b' def fs_repo_only(request, rhodecode_fixt'
232 return fs_repo_fabric
232 return fs_repo_fabric
233
233
234
234
235 @pytest.fixture
235 @pytest.fixture()
236 def enable_webhook_push_integration(request):
236 def enable_webhook_push_integration(request):
237 integration = Integration()
237 integration = Integration()
238 integration.integration_type = WebhookIntegrationType.key
238 integration.integration_type = WebhookIntegrationType.key
@@ -269,7 +269,7 b' def enable_webhook_push_integration(requ'
269 Session().commit()
269 Session().commit()
270
270
271
271
272 @pytest.fixture
272 @pytest.fixture()
273 def branch_permission_setter(request):
273 def branch_permission_setter(request):
274 """
274 """
275
275
General Comments 0
You need to be logged in to leave comments. Login now