Skip to content

Commit 0804cae

Browse files
committed
fixed linting
upgraded pep8 to pycodestlye and fixed linting errors which now covers tests too. Change-Id: Ib9b470a83d1882d110cdefe0755f93e7f9d69b76
1 parent e7f8bc0 commit 0804cae

File tree

12 files changed

+65
-39
lines changed

12 files changed

+65
-39
lines changed

rdopkg/actionmods/cbsbuild.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def retrieve_sources():
9393
return
9494
try:
9595
specfile = spec_fn()
96-
except:
96+
except Exception:
9797
return
9898

9999
cmd = [spectool, "-g", specfile]
@@ -113,7 +113,7 @@ def create_srpm(dist='el7'):
113113
try:
114114
specfile = spec_fn()
115115
spec = Spec(specfile)
116-
except:
116+
except Exception:
117117
return
118118

119119
rpmdefines = ["--define 'dist .{}'".format(dist),

rdopkg/actionmods/rdoinfo.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,19 @@ def print_releases(self):
199199
print(s)
200200
for repo in rls['repos']:
201201
if 'special' in repo:
202-
print (" {t.bold}{name}{t.normal}: "
203-
"{t.yellow}{special}{t.normal}".format(
204-
t=log.term,
205-
name=repo['name'],
206-
special=repo['special']))
202+
print(" {t.bold}{name}{t.normal}: "
203+
"{t.yellow}{special}{t.normal}".format(
204+
t=log.term,
205+
name=repo['name'],
206+
special=repo['special']))
207207
else:
208-
print (" {t.bold}{name}{t.normal} built in"
209-
" {t.bold}{bs}{t.normal} from"
210-
" {t.bold}{branch}{t.normal} branch".format(
211-
t=log.term,
212-
name=repo['name'],
213-
bs=repo.get('buildsys', '??'),
214-
branch=repo['branch']))
208+
print(" {t.bold}{name}{t.normal} built in"
209+
" {t.bold}{bs}{t.normal} from"
210+
" {t.bold}{branch}{t.normal} branch".format(
211+
t=log.term,
212+
name=repo['name'],
213+
bs=repo.get('buildsys', '??'),
214+
branch=repo['branch']))
215215

216216
def print_pkg_summary(self):
217217
pkgs = self.info['packages']

rdopkg/utils/specfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def get_patches_ignore_regex(self):
284284
regex_string = match.group(1)
285285
try:
286286
return re.compile(regex_string)
287-
except:
287+
except Exception:
288288
return None
289289

290290
def _create_new_patches_base(self, base):

run_tests.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/sh
2-
set -ex
2+
set -exuo pipefail
3+
4+
# avoid possible pytest errors due to precompiled files
5+
export PYTHONDONTWRITEBYTECODE=1
6+
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf || true
37

48
PYTHONPATH=. py.test $@
5-
pep8 rdopkg
9+
python -m pycodestyle
610
./tests/test_findpkg_integration.sh

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pycodestyle]
2+
exclude=build,lib,.tox,third,*.egg,docs,packages,.eggs

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pep8
22
pytest
3+
pycodestyle

tests/test_common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ def assert_spec_version(version, release_parts, milestone):
125125
def norm_changelog(count=1):
126126
spec = Spec()
127127
txt, chl = spec.txt.split('%changelog\n')
128-
chl, n = re.subn(r'^\* .+\s(\d\S*)$', '* DATE AUTHOR \g<1>', chl, count=count, flags=re.M)
128+
chl, n = re.subn(r'^\* .+\s(\d\S*)$',
129+
'* DATE AUTHOR \g<1>',
130+
chl, count=count,
131+
flags=re.M)
129132
spec._txt = txt + '%changelog\n' + chl
130133
spec.save()

tests/test_new_version.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ def test_new_version_basic(tmpdir):
4747
def test_new_version_milestone(tmpdir):
4848
steps = [
4949
('3.4.5', '3.4.5', ('1', '', DIST_POSTFIX), None),
50-
('4.0.0.0b1', '4.0.0', ('0.1', '%{?milestone}', DIST_POSTFIX), '.0b1'),
51-
('4.0.0.0rc1', '4.0.0', ('0.2', '%{?milestone}', DIST_POSTFIX), '.0rc1'),
50+
('4.0.0.0b1',
51+
'4.0.0', ('0.1', '%{?milestone}', DIST_POSTFIX), '.0b1'),
52+
('4.0.0.0rc1',
53+
'4.0.0', ('0.2', '%{?milestone}', DIST_POSTFIX), '.0rc1'),
5254
('4.0.0', '4.0.0', ('1', '', DIST_POSTFIX), None),
5355
]
5456
_test_new_version('some', tmpdir, steps)

tests/test_patch.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ def _test_patch(asset, version, dir):
4343

4444
@pytest.mark.skipif('RPM_AVAILABLE == False')
4545
def test_patch_milestone(tmpdir):
46-
_test_patch('milestone', ('1.2.3', ('0.4', '%{?milestone}', DIST_POSTFIX), '.0rc2'), tmpdir)
46+
_test_patch('milestone', ('1.2.3', ('0.4', '%{?milestone}',
47+
DIST_POSTFIX), '.0rc2'), tmpdir)
4748

4849

4950
@pytest.mark.skipif('RPM_AVAILABLE == False')
5051
def test_patch_milestone_bug(tmpdir):
5152
# make sure rdopkg removes unwanted '%global milestone %{?milestone}'
52-
_test_patch('milestone-bug', ('1.2.3', ('0.4', '', DIST_POSTFIX), None), tmpdir)
53+
_test_patch('milestone-bug',
54+
('1.2.3', ('0.4', '', DIST_POSTFIX), None),
55+
tmpdir)
5356

5457

5558
@pytest.mark.skipif('RPM_AVAILABLE == False')
@@ -126,11 +129,13 @@ def test_patch_noop(tmpdir):
126129

127130

128131
def test_patch_noop_detect(tmpdir):
129-
_test_patch_noop(tmpdir, 'patched', ['patch', '-l', '--changelog', 'detect'])
132+
_test_patch_noop(tmpdir,
133+
'patched', ['patch', '-l', '--changelog', 'detect'])
130134

131135

132136
def test_patch_noop_count(tmpdir):
133-
_test_patch_noop(tmpdir, 'patched', ['patch', '-l', '--changelog', 'count'])
137+
_test_patch_noop(tmpdir,
138+
'patched', ['patch', '-l', '--changelog', 'count'])
134139

135140

136141
def test_patch_noop_plain(tmpdir):
@@ -141,7 +146,8 @@ def test_patch_noop_no_bump(tmpdir):
141146
_test_patch_noop(tmpdir, 'patched', ['patch', '-l', '--no-bump'])
142147

143148

144-
def _test_patch_regen(tmpdir, distgit, distgit_after, cmd, norm_changelog=True):
149+
def _test_patch_regen(tmpdir, distgit, distgit_after,
150+
cmd, norm_changelog=True):
145151
dist_path = common.prep_spec_test(tmpdir, distgit)
146152
with dist_path.as_cwd():
147153
common.prep_patches_branch()
@@ -153,7 +159,8 @@ def _test_patch_regen(tmpdir, distgit, distgit_after, cmd, norm_changelog=True):
153159
if norm_changelog:
154160
common.norm_changelog()
155161
common.assert_distgit(dist_path, distgit_after)
156-
assert commit_before != commit_after, "New commit not created after patch regen"
162+
assert commit_before != commit_after, \
163+
"New commit not created after patch regen"
157164
assert git_clean, "git not clean after action"
158165

159166

@@ -162,16 +169,20 @@ def test_patch_regen(tmpdir):
162169

163170

164171
def test_patch_regen_detect(tmpdir):
165-
_test_patch_regen(tmpdir, 'patched', 'patched-regen', ['patch', '-l', '-C', 'detect'])
172+
_test_patch_regen(tmpdir, 'patched', 'patched-regen',
173+
['patch', '-l', '-C', 'detect'])
166174

167175

168176
def test_patch_regen_count(tmpdir):
169-
_test_patch_regen(tmpdir, 'patched', 'patched-regen', ['patch', '-l', '-C', 'count'])
177+
_test_patch_regen(tmpdir, 'patched', 'patched-regen',
178+
['patch', '-l', '-C', 'count'])
170179

171180

172181
def test_patch_regen_plain(tmpdir):
173-
_test_patch_regen(tmpdir, 'patched', 'patched-regen', ['patch', '-l', '--changelog', 'plain'])
182+
_test_patch_regen(tmpdir, 'patched', 'patched-regen',
183+
['patch', '-l', '--changelog', 'plain'])
174184

175185

176186
def test_patch_regen_no_bump(tmpdir):
177-
_test_patch_regen(tmpdir, 'patched', 'patched', ['patch', '-l', '--no-bump'], norm_changelog=False)
187+
_test_patch_regen(tmpdir, 'patched', 'patched',
188+
['patch', '-l', '--no-bump'], norm_changelog=False)

tests/test_spec.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def test_set_patches_base_case_2_minimal():
201201
assert spec.txt == 'foo\nbaz\n'
202202

203203

204-
# found bug where following comment mangles prior line when clearing patches_base
204+
# found bug where following comment mangles prior line when clearing
205+
# patches_base
205206
def test_set_patches_base_case_3_minimal():
206207
spec = specfile.Spec(txt='foo\n# patches_base=1.2.3\n# bar\nbaz\n')
207208
spec.set_patches_base_version(None)
@@ -230,7 +231,7 @@ def test_set_patches_base_case_5_minimal():
230231

231232
# patches_base/patches_ignore
232233
def test_set_patches_base_case_6_minimal():
233-
spec = specfile.Spec(txt='Version: 1.2.3\n\n# patches_base=1.2.3\n# patches_ignore=DROP-IN-RPM\n#\nPatch0=foo.patch\n')
234+
spec = specfile.Spec(txt='Version: 1.2.3\n\n# patches_base=1.2.3\n# patches_ignore=DROP-IN-RPM\n#\nPatch0=foo.patch\n') # noqa
234235
spec.set_patches_base_version(None)
235236
assert 'Version: 1.2.3\n' in spec.txt
236237
assert '# patches_ignore=DROP-IN-RPM\n' in spec.txt
@@ -239,7 +240,7 @@ def test_set_patches_base_case_6_minimal():
239240

240241
# patches_ignore/patches_base
241242
def test_set_patches_base_case_7_minimal():
242-
spec = specfile.Spec(txt='Version: 1.2.3\n\n# patches_ignore=DROP-IN-RPM\n# patches_base=1.2.3\n#\nPatch0=foo.patch\n')
243+
spec = specfile.Spec(txt='Version: 1.2.3\n\n# patches_ignore=DROP-IN-RPM\n# patches_base=1.2.3\n#\nPatch0=foo.patch\n') # noqa
243244
spec.set_patches_base_version(None)
244245
assert 'Version: 1.2.3\n' in spec.txt
245246
assert '# patches_ignore=DROP-IN-RPM\n' in spec.txt
@@ -248,7 +249,7 @@ def test_set_patches_base_case_7_minimal():
248249

249250
# patches_ignore/patches_base keep patches_base
250251
def test_set_patches_base_case_8_minimal():
251-
spec = specfile.Spec(txt='Version: 1.2.3\n\n# patches_ignore=DROP-IN-RPM\n# patches_base=\n#\nPatch0=foo.patch\n')
252+
spec = specfile.Spec(txt='Version: 1.2.3\n\n# patches_ignore=DROP-IN-RPM\n# patches_base=\n#\nPatch0=foo.patch\n') # noqa
252253
spec.set_patches_base_version(None)
253254
assert '# patches_ignore=DROP-IN-RPM\n' in spec.txt
254255
assert '# patches_base=1.2.3\n' in spec.txt
@@ -310,7 +311,8 @@ def test_get_magic_comment_minimal_6():
310311
assert spec.get_magic_comment('foo') is None
311312

312313

313-
@pytest.mark.skip('Ignoring eged case until we get more details for expected behavior')
314+
@pytest.mark.skip(
315+
'Ignoring eged case until we get more details for expected behavior')
314316
def test_get_magic_comment_minimal_7():
315317
spec = specfile.Spec(txt='# foo=\n')
316318
assert '' == spec.get_magic_comment('foo')

0 commit comments

Comments
 (0)