Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2382891

Browse files
committed
Test that deprecated Diff.renamed property warns
This starts on a test.deprecation subpackage for deprecation tests.Having these tests in a separate directory inside the test suitemay or may not be how they will ultimately be orgnaized, but it hastwo advantages:- Once all the tests are written, it should be easy to see what in GitPython is deprecated.- Some deprecation warnings -- those on module or class attribute access -- will require the introduction of new dynamic behavior, and thus run the risk of breaking static type checking. So that should be checked for, where applicable. But currently the test suite has no type annotations and is not checked by mypy. Having deprecation-related tests under the same path will make it easier to enable mypy for just this part of the test suite (for now).It is also for this latter reason that the one test so far iswritten without using the GitPython test suite's existing fixtureswhose uses are harder to annotate. This may be changed ifwarranted, though some of the more complex deprecation-relatedtests may benefit from being written as pure pytest tests.Although a number of deprecated features in GitPython do alreadyissue warnings, Diff.renamed is one of the features that does notyet do so. So the newly introduced test will fail until that isfixed in the next commit.
1 parent64ec0b1 commit2382891

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎test/deprecation/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This module is part of GitPython and is released under the
2+
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

‎test/deprecation/test_various.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This module is part of GitPython and is released under the
2+
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
3+
4+
"""Tests of assorted deprecation warnings with no extra subtleties to check."""
5+
6+
fromgit.diffimportNULL_TREE
7+
fromgit.repoimportRepo
8+
9+
importpytest
10+
11+
12+
deftest_diff_renamed_warns(tmp_path):
13+
(tmp_path/"a.txt").write_text("hello\n",encoding="utf-8")
14+
repo=Repo.init(tmp_path)
15+
repo.index.add(["a.txt"])
16+
commit=repo.index.commit("Initial commit")
17+
(diff,)=commit.diff(NULL_TREE)# Exactly one file in the diff.
18+
19+
withpytest.deprecated_call():
20+
diff.renamed

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp