FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gitdb/gitdb/test/db/test_git.py at master · gitpython-developers/gitdb · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Jul 26, 2026. It is now read-only.
gitpython-developers
/
gitdb
Public archive
Notifications
You must be signed in to change notification settings
Fork
68
Star
227
Code
Issues
6
Pull requests
0
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
gitdb
/
gitdb
/
test
/
db
/
test_git.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (43 loc) · 1.76 KB
Breadcrumbs
gitdb
/
gitdb
/
test
/
db
/
test_git.py
Copy path
File metadata and controls
53 lines (43 loc) · 1.76 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors
#
# This module is part of GitDB and is released under
# the New BSD License: https://opensource.org/license/bsd-3-clause/
import
os
from
gitdb
.
test
.
db
.
lib
import
(
TestDBBase
,
with_rw_directory
)
from
gitdb
.
exc
import
BadObject
from
gitdb
.
db
import
GitDB
from
gitdb
.
base
import
OStream
,
OInfo
from
gitdb
.
util
import
bin_to_hex
class
TestGitDB
(
TestDBBase
):
def
test_reading
(
self
):
gdb
=
GitDB
(
os
.
path
.
join
(
self
.
gitrepopath
,
'objects'
))
# we have packs and loose objects, alternates doesn't necessarily exist
assert
1
<
len
(
gdb
.
databases
())
<
4
# access should be possible
gitdb_sha
=
next
(
gdb
.
sha_iter
())
assert
isinstance
(
gdb
.
info
(
gitdb_sha
),
OInfo
)
assert
isinstance
(
gdb
.
stream
(
gitdb_sha
),
OStream
)
ni
=
50
assert
gdb
.
size
()
>=
ni
sha_list
=
list
(
gdb
.
sha_iter
())
assert
len
(
sha_list
)
==
gdb
.
size
()
sha_list
=
sha_list
[:
ni
]
# speed up tests ...
# This is actually a test for compound functionality, but it doesn't
# have a separate test module
# test partial shas
# this one as uneven and quite short
gitdb_sha_hex
=
bin_to_hex
(
gitdb_sha
)
assert
gdb
.
partial_to_complete_sha_hex
(
gitdb_sha_hex
[:
5
])
==
gitdb_sha
# mix even/uneven hexshas
for
i
,
binsha
in
enumerate
(
sha_list
):
assert
gdb
.
partial_to_complete_sha_hex
(
bin_to_hex
(
binsha
)[:
8
-
(
i
%
2
)])
==
binsha
# END for each sha
self
.
assertRaises
(
BadObject
,
gdb
.
partial_to_complete_sha_hex
,
"0000"
)
@
with_rw_directory
def
test_writing
(
self
,
path
):
gdb
=
GitDB
(
path
)
# its possible to write objects
self
.
_assert_object_writing
(
gdb
)
Back
|
FazBrowse Home
|
New Git URL