Skip to content

Commit

Permalink
MAINT: Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Jan 2, 2023
1 parent 82cb410 commit 02d1c1c
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 32 deletions.
2 changes: 1 addition & 1 deletion asv/plugins/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, url, mirror_path):
'init.defaultBranch',
], display_error=False,
cwd=None).strip()
except:
except util.ProcessError:
self._default_branch = 'master'

if self.is_local_repo(url):
Expand Down
3 changes: 2 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


def pytest_addoption(parser):
parser.addoption("--webdriver", action="store", default="None",
help=("Selenium WebDriver interface to use for running the test. "
Expand Down
6 changes: 3 additions & 3 deletions test/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

from asv import benchmarks, config, environment, util
from asv.repo import get_repo
from asv import util

from . import tools

# Variables
try:
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'
],display_error=False).strip()
except:
], display_error=False).strip()
except util.ProcessError:
defaultBranch = 'master'


BENCHMARK_DIR = join(dirname(__file__), 'benchmark')

INVALID_BENCHMARK_DIR = join(
Expand Down
2 changes: 1 addition & 1 deletion test/test_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_compare_name_lookup(dvcs_type, capsys, tmpdir, example_results):
'config',
'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'

branch_name = defaultBranch if dvcs_type == 'git' else 'default'
Expand Down
2 changes: 1 addition & 1 deletion test/test_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'config', 'init.defaultBranch'],
display_error=False
).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


Expand Down
2 changes: 1 addition & 1 deletion test/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def test_build_isolation(tmpdir):
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'

commit_hash = dvcs.get_hash(f"{defaultBranch}")
Expand Down
19 changes: 12 additions & 7 deletions test/test_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from asv.util import check_output, which
from asv.util import check_output, which, ProcessError

from . import tools
from .conftest import generate_basic_conf
Expand All @@ -13,12 +13,13 @@

# Variables
try:
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
defaultBranch = check_output([which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except ProcessError:
defaultBranch = 'master'


def test_find(capfd, tmpdir):
values = [
(None, None),
Expand All @@ -38,7 +39,9 @@ def test_find(capfd, tmpdir):
dummy_packages=False)

# Test find at least runs
tools.run_asv_with_conf(conf, 'find', f"{defaultBranch}~5..{defaultBranch}", "params_examples.track_find_test",
tools.run_asv_with_conf(conf, 'find',
f"{defaultBranch}~5..{defaultBranch}",
"params_examples.track_find_test",
_machine_file=machine_file)

# Check it found the first commit after the initially tested one
Expand All @@ -63,7 +66,9 @@ def test_find_timeout(capfd, tmpdir):
dummy_packages=False)

# Test find at least runs
tools.run_asv_with_conf(conf, 'find', "-e", f"{defaultBranch}", "params_examples.time_find_test_timeout",
tools.run_asv_with_conf(conf, 'find', "-e",
f"{defaultBranch}",
"params_examples.time_find_test_timeout",
_machine_file=machine_file)

# Check it found the first commit after the initially tested one
Expand Down
3 changes: 2 additions & 1 deletion test/test_gh_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


@pytest.mark.parametrize("rewrite", [False, True], ids=["no-rewrite", "rewrite"])
def test_gh_pages(rewrite, tmpdir, generate_result_dir, monkeypatch):
tmpdir = os.path.abspath(str(tmpdir))
Expand Down
7 changes: 5 additions & 2 deletions test/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


def test_publish(tmpdir, example_results):
tmpdir = str(tmpdir)
os.chdir(tmpdir)
Expand Down Expand Up @@ -138,7 +139,9 @@ def check_file(branch, cython):
'os': 'Linux (Fedora 20)',
'python': '2.7',
'ram': '8.2G'}
for cython in ["", None] for branch in [f"{defaultBranch}", "some-branch"]]
for cython in ["",
None] for branch in [f"{defaultBranch}",
"some-branch"]]
d = dict(expected_graph_list[0])
d['ram'] = 8804682956.8
expected_graph_list.append(d)
Expand Down
24 changes: 16 additions & 8 deletions test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


def _test_generic_repo(conf, tmpdir, hash_range, master, branch, is_remote=False):
workcopy_dir = tempfile.mkdtemp(dir=tmpdir, prefix="workcopy")
os.rmdir(workcopy_dir)
Expand Down Expand Up @@ -98,8 +99,10 @@ def _test_branches(conf, branch_commits, require_describe=False):
def test_repo_git(tmpdir):
tmpdir = str(tmpdir)

dvcs = tools.generate_test_repo(tmpdir, list(range(10)), dvcs_type='git',
extra_branches=[(f'{defaultBranch}~4', 'some-branch', [11, 12, 13])])
dvcs = tools.generate_test_repo(tmpdir, list(range(10)),
dvcs_type='git',
extra_branches=[(f'{defaultBranch}~4',
'some-branch', [11, 12, 13])])

mirror_dir = join(tmpdir, "repo")

Expand All @@ -114,8 +117,10 @@ def test_it(is_remote=False):

conf.branches = [f'{defaultBranch}', 'some-branch']
branch_commits = {
f'{defaultBranch}': [dvcs.get_hash(f'{defaultBranch}'), dvcs.get_hash(f'{defaultBranch}~6')],
'some-branch': [dvcs.get_hash('some-branch'), dvcs.get_hash('some-branch~6')]
f'{defaultBranch}': [dvcs.get_hash(f'{defaultBranch}'),
dvcs.get_hash(f'{defaultBranch}~6')],
'some-branch': [dvcs.get_hash('some-branch'),
dvcs.get_hash('some-branch~6')]
}
_test_branches(conf, branch_commits, require_describe=True)

Expand Down Expand Up @@ -271,14 +276,17 @@ def test_git_submodule(tmpdir):
commit_hash_0 = dvcs.get_hash(f"{defaultBranch}")

# State 1 (one submodule)
dvcs.run_git(['-c','protocol.file.allow=always', 'submodule', 'add', sub_dvcs.path, 'sub1'])
dvcs.run_git(['-c', 'protocol.file.allow=always',
'submodule', 'add', sub_dvcs.path, 'sub1'])
dvcs.commit('Add sub1')
commit_hash_1 = dvcs.get_hash(f"{defaultBranch}")

# State 2 (one submodule with sub-submodule)
dvcs.run_git(['-c','protocol.file.allow=always', 'submodule', 'update', '--init'])
dvcs.run_git(['-c', 'protocol.file.allow=always',
'submodule', 'update', '--init'])
sub1_dvcs = tools.Git(join(dvcs.path, 'sub1'))
sub_dvcs.run_git(['-c','protocol.file.allow=always', 'submodule', 'add', ssub_dvcs.path, 'ssub1'])
sub_dvcs.run_git(['-c', 'protocol.file.allow=always',
'submodule', 'add', ssub_dvcs.path, 'ssub1'])
sub_dvcs.commit('Add sub1')
sub1_dvcs.run_git(['pull'])
dvcs.run_git(['add', 'sub1'])
Expand Down
3 changes: 2 additions & 1 deletion test/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


def test_set_commit_hash(capsys, existing_env_conf):
tmpdir, local, conf, machine_file = existing_env_conf

Expand Down
3 changes: 2 additions & 1 deletion test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch',
], display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


def _rebuild_basic_html(basedir):
local = abspath(dirname(__file__))
cwd = os.getcwd()
Expand Down
5 changes: 2 additions & 3 deletions test/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@

from . import tools

from pathlib import Path

# Variables
try:
defaultBranch = util.check_output([util.which('git'),
'config', 'init.defaultBranch'],
display_error=False).strip()
except:
except util.ProcessError:
defaultBranch = 'master'


def test_run_publish(capfd, basic_conf_2):
tmpdir, local, conf, machine_file = basic_conf_2
tmpdir = util.long_path(tmpdir)
Expand Down
2 changes: 1 addition & 1 deletion test/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_branch_hashes(self, branch=None):
try:
branch = self.run_git(["config", "init.defaultBranch"],
display_error=False).strip()
except:
except util.ProcessError:
branch = 'master'
return [x.strip() for x in self.run_git(['rev-list', branch]).splitlines()
if x.strip()]
Expand Down

0 comments on commit 02d1c1c

Please sign in to comment.