Skip to content

Commit cf5cb0c

Browse files
authored
[Tests] Replace flake9 with flake8. (atlassian-api#654)
* [Tests] Replace flake9 with flake8. * Fix tests.
1 parent eec2934 commit cf5cb0c

10 files changed

+36
-40
lines changed

atlassian/bitbucket/server/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def update(self, **kwargs):
8282
8383
:return: True if the update was successful
8484
"""
85-
if self.__can_update == False:
85+
if self.__can_update is False:
8686
raise NotImplementedError("Update not implemented for this object type.")
8787
data = self.put(None, data=kwargs)
8888
if "errors" in data:
@@ -97,7 +97,7 @@ def delete(self):
9797
9898
:return: True if delete was successful
9999
"""
100-
if self.__can_delete == False:
100+
if self.__can_delete is False:
101101
raise NotImplementedError("Delete not implemented for this object type.")
102102
data = super(BitbucketServerBase, self).delete(None)
103103
if "errors" in data:

examples/jira/jira_issue_update_epic_link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def main():
1414
epic_link_custom_field_id = "customfield_1404" # Epic Link Custom Field
1515
target_epic_issue_key = "ARA-1314"
1616
for issue_key in update_issues:
17-
issue_data = jira.update_issue_field(issue_key, fields={epic_link_custom_field_id: target_epic_issue_key})
17+
jira.update_issue_field(issue_key, fields={epic_link_custom_field_id: target_epic_issue_key})
1818
print(f"updated for {issue_key}")
1919
print("done")
2020

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
# setup.cfg or other tool-specific files.
55
# https://github.com/carlosperate/awesome-pyproject
66

7-
[tool.flake8]
8-
max-line-length = 120
9-
exclude = '.tox,docs'
10-
117
[tool.black]
128
line-length = 120
139
include = '(atlassian|examples|tests)\/.*(\.py|GET|POST)'

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mock
22
-r requirements.txt
3-
flake9
3+
flake8
44
pytest
55
pylint
66
tox

setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[pep8]
22
max-line-length = 120
33

4+
[flake8]
5+
max-line-length = 120
6+
ignore = E203,E501
7+
exclude = .tox,docs
8+
49
[mypy]
510
ignore_missing_imports = True
611

tests/mockup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
import os
44

5-
from unittest.mock import Mock, MagicMock
5+
from unittest.mock import Mock
66

77
from requests import Session, Response
88

@@ -47,8 +47,8 @@ def request_mookup(*args, **kwargs):
4747
cur_dict = elem if item is None else elem.get(item, {})
4848
if "links" in cur_dict:
4949
for link in cur_dict["links"].values():
50-
for l in link if type(link) is list else [link]:
51-
l["href"] = "{}/{}".format(SERVER, l["href"])
50+
for ld in link if type(link) is list else [link]:
51+
ld["href"] = "{}/{}".format(SERVER, ld["href"])
5252
if "next" in data:
5353
data["next"] = "{}/{}".format(SERVER, data["next"])
5454

tests/test_bitbucket_cloud.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# coding: utf8
2-
import os
3-
import requests
42
import pytest
53
import sys
64

@@ -62,7 +60,7 @@ def test_get_pipeline_step_log_1(self):
6260
result = BITBUCKET.get_pipeline_step_log(
6361
"TestWorkspace1", "testrepository1", "{PipelineUuid}", "{PipelineStep1Uuid}"
6462
)
65-
assert result == None, "Result of step1 [get_pipeline_step_log(...)]"
63+
assert result is None, "Result of step1 [get_pipeline_step_log(...)]"
6664

6765
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
6866
def test_get_pipeline_step_log_2(self):
@@ -129,9 +127,9 @@ def test_get_default_reviewers(self):
129127
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
130128
def test_is_default_reviewer(self):
131129
result = BITBUCKET.is_default_reviewer("TestWorkspace1", "testrepository1", "DefaultReviewerNo")
132-
assert result == False, "Result of [is_default_reviewer(...)]"
130+
assert result is False, "Result of [is_default_reviewer(...)]"
133131
result = BITBUCKET.is_default_reviewer("TestWorkspace1", "testrepository1", "DefaultReviewer1")
134-
assert result == True, "Result of [is_default_reviewer(...)]"
132+
assert result is True, "Result of [is_default_reviewer(...)]"
135133

136134
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
137135
def test_delete_default_reviewer(self):

tests/test_bitbucket_server.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# coding: utf8
2-
import os
3-
import requests
42
import pytest
53
import sys
64

@@ -38,7 +36,7 @@ def test_global_permissions(self):
3836

3937
group = BITBUCKET.groups.get("group_a")
4038
assert group.name == "group_a", "Get a group"
41-
assert group.delete() == True, "Delete a group"
39+
assert group.delete() is True, "Delete a group"
4240

4341
result = list(BITBUCKET.users.each())
4442
assert [x.permission for x in result] == [
@@ -78,7 +76,7 @@ def test_global_permissions(self):
7876

7977
user = BITBUCKET.users.get("jcitizen1")
8078
assert user.name == "jcitizen1", "Get a user"
81-
assert user.delete() == True, "Delete a user"
79+
assert user.delete() is True, "Delete a user"
8280

8381
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
8482
def test_projects(self):
@@ -102,9 +100,9 @@ def test_projects(self):
102100
project.description = "New description."
103101
assert project.description == "New description.", "Update the project description"
104102

105-
assert project.public == True, "The project public flag"
103+
assert project.public is True, "The project public flag"
106104
project.public = False
107-
assert project.public == False, "Update the project public flag"
105+
assert project.public is False, "Update the project public flag"
108106

109107
assert project.key == "PRJ", "The project key"
110108
project.key = "NEWKEY"
@@ -127,7 +125,7 @@ def test_project_permissions(self):
127125

128126
group = project.groups.get("group_a")
129127
assert group.name == "group_a", "Get a group"
130-
assert group.delete() == True, "Delete a group"
128+
assert group.delete() is True, "Delete a group"
131129

132130
result = list(project.users.each())
133131
assert [x.permission for x in result] == ["ADMIN", "WRITE", "READ"], "Each permission of project user"
@@ -159,7 +157,7 @@ def test_project_permissions(self):
159157

160158
user = project.users.get("jcitizen1")
161159
assert user.name == "jcitizen1", "Get a user"
162-
assert user.delete() == True, "Delete a user"
160+
assert user.delete() is True, "Delete a user"
163161

164162
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
165163
def test_repositories(self):
@@ -189,13 +187,13 @@ def test_repositories(self):
189187
repo.description = "New description."
190188
assert repo.description == "New description.", "Update the repo description"
191189

192-
assert repo.public == True, "The repo public flag"
190+
assert repo.public is True, "The repo public flag"
193191
repo.public = False
194-
assert repo.public == False, "Update the repo public flag"
192+
assert repo.public is False, "Update the repo public flag"
195193

196-
assert repo.forkable == True, "The repo forkable flag"
194+
assert repo.forkable is True, "The repo forkable flag"
197195
repo.forkable = False
198-
assert repo.forkable == False, "Update the repo forkable flag"
196+
assert repo.forkable is False, "Update the repo forkable flag"
199197

200198
assert repo.contributing() == "Test contributing.md", "The contributing.md"
201199
assert repo.contributing(at="CommitId") == "Test contributing.md at CommitId", "The contributing.md at CommitId"
@@ -239,7 +237,7 @@ def test_repository_permissions(self):
239237

240238
group = repo.groups.get("group_a")
241239
assert group.name == "group_a", "Get a group"
242-
assert group.delete() == True, "Delete a group"
240+
assert group.delete() is True, "Delete a group"
243241

244242
result = list(repo.users.each())
245243
assert [x.permission for x in result] == ["ADMIN", "WRITE", "READ"], "Each permission of repo user"
@@ -267,4 +265,4 @@ def test_repository_permissions(self):
267265

268266
user = repo.users.get("jcitizen1")
269267
assert user.name == "jcitizen1", "Get a user"
270-
assert user.delete() == True, "Delete a user"
268+
assert user.delete() is True, "Delete a user"

tests/test_servicedesk.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# coding: utf8
2-
import os
32
import pytest
43
import sys
54

@@ -54,31 +53,31 @@ def test_create_organization(self):
5453
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
5554
def test_add_organization(self):
5655
result = SERVICEDESK.add_organization("{serviceDeskId}", "{organizationId}")
57-
assert result == None, "Result of [add_organization(...)]"
56+
assert result is None, "Result of [add_organization(...)]"
5857

5958
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
6059
def test_remove_organization(self):
6160
result = SERVICEDESK.remove_organization("{serviceDeskId}", "{organizationId}")
62-
assert result == None, "Result of [remove_organization(...)]"
61+
assert result is None, "Result of [remove_organization(...)]"
6362

6463
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
6564
def test_delete_organization(self):
6665
result = SERVICEDESK.delete_organization("{organizationId}")
67-
assert result == None, "Result of [delete_organization(...)]"
66+
assert result is None, "Result of [delete_organization(...)]"
6867

6968
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
7069
def test_add_users_to_organization(self):
7170
result = SERVICEDESK.add_users_to_organization(
7271
"{organizationId}", account_list=["{accountId1}", "{accountId2}"]
7372
)
74-
assert result == None, "Result of [add_users_to_organization(...)]"
73+
assert result is None, "Result of [add_users_to_organization(...)]"
7574

7675
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
7776
def test_remove_users_from_organization(self):
7877
result = SERVICEDESK.remove_users_from_organization(
7978
"{organizationId}", account_list=["{accountId1}", "{accountId2}"]
8079
)
81-
assert result == None, "Result of [remove_users_from_organization(...)]"
80+
assert result is None, "Result of [remove_users_from_organization(...)]"
8281

8382
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
8483
def test_get_customers(self):
@@ -88,9 +87,9 @@ def test_get_customers(self):
8887
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
8988
def test_add_customers(self):
9089
result = SERVICEDESK.add_customers("{serviceDeskId}", list_of_accountids=["{accountId1}", "{accountId2}"])
91-
assert result == None, "Result of [remove_users_from_organization(...)]"
90+
assert result is None, "Result of [remove_users_from_organization(...)]"
9291

9392
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
9493
def test_remove_customers(self):
9594
result = SERVICEDESK.remove_customers("{serviceDeskId}", list_of_accountids=["{accountId1}", "{accountId2}"])
96-
assert result == None, "Result of [remove_users_from_organization(...)]"
95+
assert result is None, "Result of [remove_users_from_organization(...)]"

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ deps = pytest
1010
commands = pytest -v
1111
extras = kerberos
1212

13-
[testenv:flake9]
13+
[testenv:flake8]
1414
basepython = python3
1515
skip_install = true
16-
deps = flake9 # flake9 is a fork of flake8 which supports pyproject.toml files
16+
deps = flake8
1717
commands = flake8
1818

1919
[testenv:pylint]

0 commit comments

Comments
 (0)