Skip to content

Commit 6b2eb38

Browse files
committed
ruff check/format in test directory
1 parent 3c5ac56 commit 6b2eb38

10 files changed

+24
-33
lines changed

test/test_branch_empty.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def test_branches_upstream_name(repo):
8484
# Low level API written in C, repo.remotes call these.
8585
#
8686

87+
8788
def test_lookup_branch_remote(repo):
8889
branch = repo.lookup_branch('origin/master', BranchType.REMOTE)
8990
assert str(branch.target) == ORIGIN_MASTER_COMMIT

test/test_config.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,23 @@ def test_multivar():
155155
config.add_file(CONFIG_FILENAME, 6)
156156
assert 'this.that' in config
157157

158-
l = list(config.get_multivar('this.that'))
159-
assert ['foobar', 'foobeer'] == l
160-
l = list(config.get_multivar('this.that', 'bar'))
161-
assert ['foobar'] == l
162-
163-
l = list(config.get_multivar('this.that', 'foo.*'))
164-
assert ['foobar', 'foobeer'] == l
158+
assert ['foobar', 'foobeer'] == list(config.get_multivar('this.that'))
159+
assert ['foobar'] == list(config.get_multivar('this.that', 'bar'))
160+
assert ['foobar', 'foobeer'] == list(config.get_multivar('this.that', 'foo.*'))
165161

166162
config.set_multivar('this.that', '^.*beer', 'fool')
167-
l = list(config.get_multivar('this.that', 'fool'))
168-
assert ['fool'] == l
163+
assert ['fool'] == list(config.get_multivar('this.that', 'fool'))
169164

170165
config.set_multivar('this.that', 'foo.*', 'foo-123456')
171-
l = list(config.get_multivar('this.that', 'foo.*'))
172-
assert ['foo-123456', 'foo-123456'] == l
166+
assert ['foo-123456', 'foo-123456'] == list(
167+
config.get_multivar('this.that', 'foo.*')
168+
)
173169

174170
config.delete_multivar('this.that', 'bar')
175-
l = list(config.get_multivar('this.that', ''))
176-
assert ['foo-123456', 'foo-123456'] == l
171+
assert ['foo-123456', 'foo-123456'] == list(config.get_multivar('this.that', ''))
177172

178173
config.delete_multivar('this.that', 'foo-[0-9]+')
179-
l = list(config.get_multivar('this.that', ''))
180-
assert [] == l
174+
assert [] == list(config.get_multivar('this.that', ''))
181175

182176

183177
def test_iterator(config):

test/test_object.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ def test_hashing(testrepo):
7878
assert commit_b in d
7979
assert d[commit_b]
8080

81-
l = [commit_a]
82-
assert commit_b in l
81+
assert commit_b == commit_a
8382

8483

8584
def test_peel_commit(testrepo):

test/test_odb_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def test_exists(proxy):
130130
with pytest.raises(TypeError):
131131
proxy.exists(123)
132132

133-
assert proxy.exists('1' * 40) == False
134-
assert proxy.exists(BLOB_HEX) == True
133+
assert not proxy.exists('1' * 40)
134+
assert proxy.exists(BLOB_HEX)
135135

136136

137137
def test_exists_prefix(proxy):

test/test_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_refspec(testrepo):
139139
refspec = remote.get_refspec(0)
140140
assert refspec.src == REMOTE_FETCHSPEC_SRC
141141
assert refspec.dst == REMOTE_FETCHSPEC_DST
142-
assert True == refspec.force
142+
assert refspec.force is True
143143
assert ORIGIN_REFSPEC == refspec.string
144144

145145
assert list == type(remote.fetch_refspecs)

test/test_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ def test_worktree_custom_ref(testrepo):
829829
assert testrepo.list_worktrees() == []
830830

831831
# The ref is no longer checked out
832-
assert worktree_ref.is_checked_out() == False
832+
assert worktree_ref.is_checked_out() is False
833833

834834
# The branch still exists
835835
assert branch_name in testrepo.branches

test/test_repository_bare.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ def test_contains(barerepo):
108108

109109

110110
def test_iterable(barerepo):
111-
l = [obj for obj in barerepo]
112111
oid = pygit2.Oid(hex=BLOB_HEX)
113-
assert oid in l
112+
assert oid in [obj for obj in barerepo]
114113

115114

116115
def test_lookup_blob(barerepo):

test/test_status.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import pytest
2727

28-
import pygit2
2928
from pygit2.enums import FileStatus
3029

3130

test/test_submodule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_lookup_submodule_aspath(repo):
6060

6161
def test_lookup_missing_submodule(repo):
6262
with pytest.raises(KeyError):
63-
s = repo.submodules['does-not-exist']
63+
repo.submodules['does-not-exist']
6464
assert repo.submodules.get('does-not-exist') is None
6565

6666

test/utils.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@
7272
refcount = pytest.mark.skipif(is_pypy, reason='skip refcounts checks in pypy')
7373

7474

75-
def force_rm_handle(remove_path, path, excinfo):
76-
path = Path(path)
77-
path.chmod(path.stat().st_mode | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
78-
remove_path(path)
79-
80-
8175
def gen_blob_sha1(data):
8276
# http://stackoverflow.com/questions/552659/assigning-git-sha1s-without-git
8377
m = hashlib.sha1()
@@ -86,13 +80,18 @@ def gen_blob_sha1(data):
8680
return m.hexdigest()
8781

8882

83+
def force_rm_handle(remove_path, path, excinfo):
84+
path = Path(path)
85+
path.chmod(path.stat().st_mode | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
86+
remove_path(path)
87+
88+
8989
def rmtree(path):
9090
"""In Windows a read-only file cannot be removed, and shutil.rmtree fails.
9191
So we implement our own version of rmtree to address this issue.
9292
"""
9393
if Path(path).exists():
94-
onerror = lambda func, path, e: force_rm_handle(func, path, e)
95-
shutil.rmtree(path, onerror=onerror)
94+
shutil.rmtree(path, onerror=force_rm_handle)
9695

9796

9897
class TemporaryRepository:

0 commit comments

Comments
 (0)