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

Commitac20325

Browse files
committed
Test version_info parsing
This modifies two existing test cases to include an assertion aboutthe length. These test cases are retained as there is value intesting on output from a real git command rather than only withtest doubles.More importantly, this also adds a parameterized test method tocheck parsing of:- All numeric, shorter than the limit - all fields used.- All numeric, at the limit - all fields used.- All numeric, longer than the limit - extra fields dropped.- Has unambiguous non-numeric - dropped from there on.- Has ambiguous non-numeric, negative int - dropped from there on.- Has ambiguous non-numeric, number+letter - dropped from there on.The cases for parsing when a field is not numeric (or not fully orunambiguously numeric) currently all fail, because the existinglogic drops intermediate non-numeric fields (#1833).Parsing should instead stop at (or, *perhaps* in cases like "2a",after) such fields. When the code is changed to stop at themrather than dropping them and presenting the subsequent field asthough it were a previous field, these test cases should also pass.
1 parentdc6b90f commitac20325

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

‎test/test_git.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,10 @@ def test_persistent_cat_file_command(self):
338338
self.assertEqual(size,size_two)
339339

340340
deftest_version_info(self):
341-
"""The version_info attribute is a tuple of ints."""
341+
"""The version_info attribute is a tuple ofup to fourints."""
342342
v=self.git.version_info
343343
self.assertIsInstance(v,tuple)
344+
self.assertLessEqual(len(v),4)
344345
forninv:
345346
self.assertIsInstance(n,int)
346347

@@ -349,9 +350,26 @@ def test_version_info_pickleable(self):
349350
deserialized=pickle.loads(pickle.dumps(self.git))
350351
v=deserialized.version_info
351352
self.assertIsInstance(v,tuple)
353+
self.assertLessEqual(len(v),4)
352354
forninv:
353355
self.assertIsInstance(n,int)
354356

357+
@ddt.data(
358+
(("123","456","789"), (123,456,789)),
359+
(("12","34","56","78"), (12,34,56,78)),
360+
(("12","34","56","78","90"), (12,34,56,78)),
361+
(("1","2","a","3"), (1,2)),
362+
(("1","-2","3"), (1,)),
363+
(("1","2a","3"), (1,)),# Subject to change.
364+
)
365+
deftest_version_info_is_leading_numbers(self,case):
366+
fake_fields,expected_version_info=case
367+
with_rollback_refresh():
368+
with_fake_git(*fake_fields)aspath:
369+
refresh(path)
370+
new_git=Git()
371+
self.assertEqual(new_git.version_info,expected_version_info)
372+
355373
deftest_git_exc_name_is_git(self):
356374
self.assertEqual(self.git.git_exec_name,"git")
357375

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp