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

Commit41294d5

Browse files
committed
Use the mock backport on Python 3.7
Because mock.call.kwargs, i.e. the ability to examinem.call_args.kwargs where m is a Mock or MagicMock, was introducedin Python 3.8.Currently it is only in test/test_git.py that any use of mocksrequires this, so I've put the conditional import logic to importmock (the top-level package) rather than unittest.mock only there.The mock library is added as a development (testing) dependencyonly when the Python version is lower than 3.8, so it is notinstalled when not needed.This fixes a problem in the new tests of whether a shell is used,and reported as used, in the Popen call in Git.execute. Thosejust-introduced tests need this, to be able to usemock_popen.call_args.kwargs on Python 3.7.
1 parentda3460c commit41294d5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

‎test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
black
22
coverage[toml]
3-
ddt>=1.1.1, !=1.4.3
3+
ddt >= 1.1.1, != 1.4.3
4+
mock ; python_version < "3.8"
45
mypy
56
pre-commit
67
pytest

‎test/test_git.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
importsubprocess
1414
importsys
1515
fromtempfileimportTemporaryDirectory,TemporaryFile
16-
fromunittestimportmock,skipUnless
16+
fromunittestimportskipUnless
17+
18+
ifsys.version_info>= (3,8):
19+
fromunittestimportmock
20+
else:
21+
importmock# To be able to examine call_args.kwargs on a mock.
1722

1823
importddt
1924

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp