Read about our upcoming Code of Conduct on this issue

Commit 57c04c38 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Style: abiding to rules change due to CI flake8 version change

The good thing is that we finally get back to sanity with
boolean operators. This is now legit:

   if something
      and othercondition:
parent ce67fdfe3181
Pipeline #12818 failed with stages
in 20 seconds
......@@ -11,6 +11,7 @@ flake8:
# overkill, but should already be on all our runners
image: registry.heptapod.net/heptapod/ci-images/fixed-pydeps
script:
- flake8 --version
- flake8 tests conftest.py
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
......
......@@ -196,7 +196,7 @@ def test_implicit_move(test_project, tmpdir):
assert test_project.api_branch_titles() == {
'branch/default': 'Commit on default',
'branch/other': 'Commit 2',
}
}
# now imagine a bookmark slides to the head of a branch
# first, prepare it
......@@ -214,4 +214,4 @@ def test_implicit_move(test_project, tmpdir):
'branch/default': 'Commit on default',
'branch/other': 'Commit 2',
'sliding': 'Commit 2',
}
}
......@@ -107,8 +107,8 @@ def test_import_non_topic_draft(public_project, tmpdir):
clone = LocalRepo.clone(project.owner_basic_auth_url,
tmpdir.join('repo'))
assert clone.hg('log', '-T', '{phase}', '-r', 0) == 'draft', (
"draft non-topic changeset should not become public "
"in imported repo")
"draft non-topic changeset should not become public "
"in imported repo")
assert hg_log_set(clone) == hg_log_set(src_repo)
assert project.api_default_branch() == 'branch/default'
......@@ -180,10 +180,8 @@ def test_import_bookmarks(public_project, tmpdir):
assert status == 'finished'
clone = LocalRepo.clone(project.owner_basic_auth_url,
tmpdir.join('repo'))
assert (
hg_log_set(clone, bookmarks=True) ==
hg_log_set(src_repo, bookmarks=True)
)
assert (hg_log_set(clone, bookmarks=True)
== hg_log_set(src_repo, bookmarks=True))
finally:
if project is not None:
project.api_destroy()
......@@ -47,7 +47,7 @@ def test_admin_views(heptapod):
for slug in (
'application_settings/general',
'users',
):
):
assert_webdriver_get(webdriver, '/'.join(
(heptapod.url, 'admin', slug)))
......
......@@ -606,7 +606,7 @@ def test_mergerequest_api_fast_forward_refusal_rebase(test_project, tmpdir):
"Même une antilope !:public",
"Even a horse!:public",
"Initial sentence:public",
]
]
# Commit list is correct
expected = "Même une antilope !"
......@@ -719,7 +719,7 @@ def test_mergerequest_api_explicit_merge_message(test_project, tmpdir,
"Même une antilope !:public",
"Even a horse!:public",
"Initial sentence:public",
]
]
# there's a CI job for the target
job = runner.wait_assert_one_job()
......@@ -784,7 +784,7 @@ def test_mergerequest_api_explicit_merge_multiple_heads(test_project, tmpdir):
"Même une antilope !:public",
"Even a horse!:public",
"Initial sentence:public",
]
]
# changesets from the 'flora' branch are completely untouched, they
# don't even have new descendents.
......@@ -932,7 +932,7 @@ def test_mergerequest_api_explicit_merge_user(public_project, tmpdir,
"Même une antilope !:public",
"Even a horse!:public",
"Initial sentence:public",
]
]
def test_mergerequest_api_named_branch(public_project, tmpdir):
......@@ -961,7 +961,7 @@ def test_mergerequest_api_named_branch(public_project, tmpdir):
"Le lion est prédateur du gnou !:gnu:public",
"Even a horse!:default:public",
"Initial sentence:default:public",
]
]
# Commit list is correct
expected = "Le lion est prédateur"
......@@ -1104,7 +1104,7 @@ def test_mergerequest_api_obsolete_multiple_heads(public_project, tmpdir):
"Even a zebra!:public",
"Même une antilope !:public",
"Initial sentence:public",
]
]
# Commit list is correct (recall that zebra is in the target branch)
commit_links = public_project.webdriver_get_merge_request_commits(mr_id)
......
......@@ -410,8 +410,7 @@ def test_external_user_can_create_project(test_group, external_user):
project = Project.api_retrieve(heptapod, 'root', test_group,
'ext_create')
assert (project.owner == external_user.name
or
project.creator_id == external_user.id)
or project.creator_id == external_user.id)
finally:
if project is not None:
# ugly hack until we can just pass a different user
......
from os.path import (
dirname,
join as path_join,
)
)
DATA_DIR = path_join(dirname(dirname(__file__)), 'data')
......@@ -23,11 +23,11 @@ def heptapod_exec(ct, command, user='root'):
def heptapod_run_shell(ct, command, **kw):
exit_code, output = heptapod_exec(ct, command, **kw)
if exit_code:
raise RuntimeError(('Heptapod command {command} returned a non-zero '
'exit code {exit_code}').format(
command=command,
exit_code=exit_code,
))
raise RuntimeError(
('Heptapod command {command} returned a non-zero '
'exit code {exit_code}').format(command=command,
exit_code=exit_code,
))
def heptapod_put_archive(ct, dest, path):
......
......@@ -63,7 +63,7 @@ class Group:
self.heptapod.users[user_name]['token']}
return requests.get(self.api_url, headers=headers)
def api_post(self, subpath='', **params):
def api_post(self, subpath='', **params):
user_name = self.owner_name if self.owner_name is not None else 'root'
headers = {'Private-Token':
self.heptapod.users[user_name]['token']}
......
......@@ -121,7 +121,7 @@ class Heptapod:
'exit code {exit_code}').format(
command=command,
exit_code=exit_code,
))
))
return output
def get_user(self, name):
......
......@@ -192,7 +192,7 @@ class Project(object):
address = '{heptapod.ssh_user}@{heptapod.host}:{path}'.format(
heptapod=heptapod,
path=self.relative_uri + '.git',
)
)
return cmd, address
def basic_auth_url(self, user_name, pwd=None):
......@@ -460,10 +460,10 @@ class Project(object):
def webdriver_update_merge_request_settings(self, merge_method):
driver = self.owner_webdriver
driver.get('{url}/{group_path}/{project_name}/edit'.format(
group_path=self.group.full_path,
url=self.heptapod.url,
project_name=self.name,
))
group_path=self.group.full_path,
url=self.heptapod.url,
project_name=self.name,
))
elem = driver.find_element_by_xpath(
'//section[contains(@class, "merge-requests-feature")]'
......@@ -490,14 +490,14 @@ class Project(object):
'merge_request[source_branch]': source,
'merge_request[target_project_id]': self.id,
'merge_request[target_branch]': target,
}
}
driver.get(
'{url}/{group_path}/{project_name}/merge_requests/new?{qs}'.format(
group_path=self.group.full_path,
url=heptapod.url,
project_name=self.name,
qs=urlencode(compare_qs),
))
))
assert 'New Merge Request' in driver.title
assert self.name in driver.title
......@@ -806,7 +806,7 @@ class Project(object):
confirm_button.click()
deletion_banner_re = r"Project '\w+ / {}' will be deleted.".format(
self.name)
self.name)
# storing page source in a variable to allow for investigation
# in case the regexp doesn't match and we've not been redirected
......@@ -1072,7 +1072,7 @@ class Project(object):
heptapod.api_url + '/projects',
headers=heptapod.get_user(search_as).token_headers(),
params=params
)
)
return resp
def api_transfer(self, group):
......
......@@ -68,7 +68,7 @@ class Runner:
self.wait_assert_one_job(
msg="Got only %d job(s) instead of the expected %d "
"after waiting for %d seconds" % (i, number,
(i+1) * each_timeout),
(i + 1) * each_timeout),
timeout=each_timeout,
retry_wait=each_retry_wait)
for i in range(number)]
......
......@@ -128,7 +128,7 @@ class User(object):
def ensure_ssh_pub_key(self, pubkey, title='heptapod-tests'):
hepta = self.heptapod
keys_api_url = '/'.join((
hepta.api_url, 'users', str(self.id), 'keys'))
hepta.api_url, 'users', str(self.id), 'keys'))
headers = hepta.root_token_headers
ls_resp = requests.get(keys_api_url, headers=headers)
assert ls_resp.status_code == 200
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment