Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
GitPython/test/deprecation/test_basic.py at detached-head · gitpython-developers/GitPython · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
gitpython-developers
/
GitPython
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
998
Star
5.2k
Code
Issues
7
Pull requests
2
Discussions
Actions
Security and quality
35
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Files
Expand file tree
detached-head
Breadcrumbs
GitPython
/
test
/
deprecation
/
test_basic.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
137 lines (94 loc) · 4.91 KB
detached-head
Breadcrumbs
GitPython
/
test
/
deprecation
/
test_basic.py
Copy path
Top
File metadata and controls
Code
Blame
137 lines (94 loc) · 4.91 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
"""Tests of assorted deprecation warnings when there are no extra subtleties to check.
This tests deprecation warnings where all that needs be verified is that a deprecated
property, function, or class issues a DeprecationWarning when used and, if applicable,
that recommended alternatives do not issue the warning.
This is in contrast to other modules within test.deprecation, which test warnings where
there is a risk of breaking other runtime behavior, or of breaking static type checking
or making it less useful, by introducing the warning or in plausible future changes to
how the warning is implemented. That happens when it is necessary to customize attribute
access on a module or class, in a way it was not customized before, to issue a warning.
It is inapplicable to the deprecations whose warnings are tested in this module.
"""
import
pytest
from
git
.
diff
import
NULL_TREE
from
git
.
objects
.
util
import
Traversable
from
git
.
repo
import
Repo
from
git
.
util
import
Iterable
as
_Iterable
,
IterableObj
from
.
lib
import
assert_no_deprecation_warning
# typing -----------------------------------------------------------------
from
typing
import
Generator
,
TYPE_CHECKING
if
TYPE_CHECKING
:
from
pathlib
import
Path
from
git
.
diff
import
Diff
,
DiffIndex
from
git
.
objects
.
commit
import
Commit
# ------------------------------------------------------------------------
@
pytest
.
fixture
def
commit
(
tmp_path
:
"Path"
)
->
Generator
[
"Commit"
,
None
,
None
]:
"""Fixture to supply a one-commit repo's commit, enough for deprecation tests."""
(
tmp_path
/
"a.txt"
).
write_text
(
"hello
\n
"
,
encoding
=
"utf-8"
)
repo
=
Repo
.
init
(
tmp_path
)
repo
.
index
.
add
([
"a.txt"
])
yield
repo
.
index
.
commit
(
"Initial commit"
)
repo
.
close
()
@
pytest
.
fixture
def
diff
(
commit
:
"Commit"
)
->
Generator
[
"Diff"
,
None
,
None
]:
"""Fixture to supply a single-file diff."""
(
diff
,)
=
commit
.
diff
(
NULL_TREE
)
# Exactly one file in the diff.
yield
diff
@
pytest
.
fixture
def
diffs
(
commit
:
"Commit"
)
->
Generator
[
"DiffIndex"
,
None
,
None
]:
"""Fixture to supply a DiffIndex."""
yield
commit
.
diff
(
NULL_TREE
)
def
test_diff_renamed_warns
(
diff
:
"Diff"
)
->
None
:
"""The deprecated Diff.renamed property issues a deprecation warning."""
with
pytest
.
deprecated_call
():
diff
.
renamed
def
test_diff_renamed_file_does_not_warn
(
diff
:
"Diff"
)
->
None
:
"""The preferred Diff.renamed_file property issues no deprecation warning."""
with
assert_no_deprecation_warning
():
diff
.
renamed_file
def
test_commit_trailers_warns
(
commit
:
"Commit"
)
->
None
:
"""The deprecated Commit.trailers property issues a deprecation warning."""
with
pytest
.
deprecated_call
():
commit
.
trailers
def
test_commit_trailers_list_does_not_warn
(
commit
:
"Commit"
)
->
None
:
"""The nondeprecated Commit.trailers_list property issues no deprecation warning."""
with
assert_no_deprecation_warning
():
commit
.
trailers_list
def
test_commit_trailers_dict_does_not_warn
(
commit
:
"Commit"
)
->
None
:
"""The nondeprecated Commit.trailers_dict property issues no deprecation warning."""
with
assert_no_deprecation_warning
():
commit
.
trailers_dict
def
test_traverse_list_traverse_in_base_class_warns
(
commit
:
"Commit"
)
->
None
:
"""Traversable.list_traverse's base implementation issues a deprecation warning."""
with
pytest
.
deprecated_call
():
Traversable
.
list_traverse
(
commit
)
def
test_traversable_list_traverse_override_does_not_warn
(
commit
:
"Commit"
)
->
None
:
"""Calling list_traverse on concrete subclasses is not deprecated, does not warn."""
with
assert_no_deprecation_warning
():
commit
.
list_traverse
()
def
test_traverse_traverse_in_base_class_warns
(
commit
:
"Commit"
)
->
None
:
"""Traversable.traverse's base implementation issues a deprecation warning."""
with
pytest
.
deprecated_call
():
Traversable
.
traverse
(
commit
)
def
test_traverse_traverse_override_does_not_warn
(
commit
:
"Commit"
)
->
None
:
"""Calling traverse on concrete subclasses is not deprecated, does not warn."""
with
assert_no_deprecation_warning
():
commit
.
traverse
()
def
test_iterable_inheriting_warns
()
->
None
:
"""Subclassing the deprecated git.util.Iterable issues a deprecation warning."""
with
pytest
.
deprecated_call
():
class
Derived
(
_Iterable
):
pass
def
test_iterable_obj_inheriting_does_not_warn
()
->
None
:
"""Subclassing git.util.IterableObj is not deprecated, does not warn."""
with
assert_no_deprecation_warning
():
class
Derived
(
IterableObj
):
pass
def
test_diff_iter_change_type
(
diffs
:
"DiffIndex"
)
->
None
:
"""The internal DiffIndex.iter_change_type function issues no deprecation warning."""
with
assert_no_deprecation_warning
():
for
change_type
in
diffs
.
change_type
:
[
*
diffs
.
iter_change_type
(
change_type
=
change_type
)]
You can’t perform that action at this time.