Enable black

- blackify all the python files,
- enable black in pre-commit,
- add a black tox environment.
This commit is contained in:
David Douard 2020-04-08 16:31:22 +02:00
parent 1ae75166c7
commit 93a4d8b784
97 changed files with 1734 additions and 1642 deletions

View file

@ -15,7 +15,7 @@ from .test_utils import init_db
def test_get_lister_wrong_input():
"""Unsupported lister should raise"""
with pytest.raises(ValueError) as e:
get_lister('unknown', 'db-url')
get_lister("unknown", "db-url")
assert "Invalid lister" in str(e.value)
@ -37,23 +37,22 @@ def test_get_lister_override():
db_url = init_db().url()
listers = {
'gitlab': 'https://other.gitlab.uni/api/v4/',
'phabricator': 'https://somewhere.org/api/diffusion.repository.search',
'cgit': 'https://some.where/cgit',
"gitlab": "https://other.gitlab.uni/api/v4/",
"phabricator": "https://somewhere.org/api/diffusion.repository.search",
"cgit": "https://some.where/cgit",
}
# check the override ends up defined in the lister
for lister_name, url in listers.items():
lst = get_lister(
lister_name, db_url, **{
'url': url,
'priority': 'high',
'policy': 'oneshot',
})
lister_name,
db_url,
**{"url": url, "priority": "high", "policy": "oneshot",}
)
assert lst.url == url
assert lst.config['priority'] == 'high'
assert lst.config['policy'] == 'oneshot'
assert lst.config["priority"] == "high"
assert lst.config["policy"] == "oneshot"
# check the default urls are used and not the override (since it's not
# passed)
@ -61,7 +60,7 @@ def test_get_lister_override():
lst = get_lister(lister_name, db_url)
# no override so this does not end up in lister's configuration
assert 'url' not in lst.config
assert 'priority' not in lst.config
assert 'oneshot' not in lst.config
assert "url" not in lst.config
assert "priority" not in lst.config
assert "oneshot" not in lst.config
assert lst.url == lst.DEFAULT_URL

View file

@ -10,7 +10,6 @@ from swh.lister import utils
class UtilsTest(unittest.TestCase):
def test_split_range(self):
actual_ranges = list(utils.split_range(14, 5))
self.assertEqual(actual_ranges, [(0, 5), (5, 10), (10, 14)])
@ -33,6 +32,6 @@ def init_db():
db object to ease db manipulation
"""
initdb_args = Postgresql.DEFAULT_SETTINGS['initdb_args']
initdb_args = ' '.join([initdb_args, '-E UTF-8'])
initdb_args = Postgresql.DEFAULT_SETTINGS["initdb_args"]
initdb_args = " ".join([initdb_args, "-E UTF-8"])
return Postgresql(initdb_args=initdb_args)