本文整理汇总了Python中book_parser.CodeListing.commit_ref方法的典型用法代码示例。如果您正苦于以下问题:Python CodeListing.commit_ref方法的具体用法?Python CodeListing.commit_ref怎么用?Python CodeListing.commit_ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类book_parser.CodeListing
的用法示例。
在下文中一共展示了CodeListing.commit_ref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_real_git_stuff
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_from_real_git_stuff(self):
listing = CodeListing(
filename="file1.txt",
contents=dedent(
"""
file 1 line 2 amended
file 1 line 3
"""
).lstrip(),
)
listing.commit_ref = "ch17l021"
self.sourcetree.apply_listing_from_commit(listing)
with open(self.sourcetree.tempdir + "/superlists/file1.txt") as f:
assert (
f.read()
== dedent(
"""
file 1 line 1
file 1 line 2 amended
file 1 line 3
"""
).lstrip()
)
assert listing.was_written
示例2: test_with_diff_listing_failure_case
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_with_diff_listing_failure_case(self):
listing = CodeListing(
filename="file2.txt",
contents=dedent(
"""
diff --git a/file2.txt b/file2.txt
index 93f054e..519d518 100644
--- a/file2.txt
+++ b/file2.txt
@@ -4,6 +4,5 @@ another line changed
some duplicate lines coming up...
hello
-hello
+something else
one more line at end
"""
).lstrip(),
)
listing.commit_ref = "ch17l030"
self._checkout_commit("ch17l029")
with self.assertRaises(ApplyCommitException):
self.sourcetree.apply_listing_from_commit(listing)
示例3: test_raises_if_listing_doesnt_show_all_new_lines_in_diff
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_raises_if_listing_doesnt_show_all_new_lines_in_diff(self):
listing = CodeListing(filename='file1.txt', contents=dedent(
"""
file 1 line 3
""").lstrip()
)
listing.commit_ref = 'ch17l021'
with self.assertRaises(ApplyCommitException):
self.sourcetree.apply_listing_from_commit(listing)
示例4: test_happy_with_lines_from_just_before_diff
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_happy_with_lines_from_just_before_diff(self):
listing = CodeListing(filename='file1.txt', contents=dedent(
"""
file 1 line 1
file 1 line 2 amended
file 1 line 3
""").lstrip()
)
listing.commit_ref = 'ch17l021'
self.sourcetree.apply_listing_from_commit(listing)
示例5: test_happy_with_js_callouts
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_happy_with_js_callouts(self):
listing = CodeListing(filename='file1.txt', contents=dedent(
"""
[...]
file 1 line 2 amended //
file 1 line 3 //
""").lstrip()
)
listing.commit_ref = 'ch17l021'
self.sourcetree.apply_listing_from_commit(listing)
示例6: test_raises_if_listing_lines_in_wrong_order
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_raises_if_listing_lines_in_wrong_order(self):
listing = CodeListing(filename='file1.txt', contents=dedent(
"""
file 1 line 3
file 1 line 2 amended
""").lstrip()
)
listing.commit_ref = 'ch17l021'
with self.assertRaises(ApplyCommitException):
self.sourcetree.apply_listing_from_commit(listing)
示例7: test_raises_if_any_other_listing_lines_not_in_before_version
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_raises_if_any_other_listing_lines_not_in_before_version(self):
listing = CodeListing(filename='file1.txt', contents=dedent(
"""
what is this?
file 1 line 2 amended
file 1 line 3
""").lstrip()
)
listing.commit_ref = 'ch17l021'
with self.assertRaises(ApplyCommitException):
self.sourcetree.apply_listing_from_commit(listing)
示例8: test_listings_showing_a_move_mean_can_ignore_commit_lines_added_and_removed_2
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_listings_showing_a_move_mean_can_ignore_commit_lines_added_and_removed_2(self):
listing = CodeListing(filename='file2.txt', contents=dedent(
"""
hello
one more line at end
""").lstrip()
)
listing.commit_ref = 'ch17l030'
self._checkout_commit('ch17l029')
self.sourcetree.apply_listing_from_commit(listing)
示例9: test_raises_if_too_many_files_in_commit
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_raises_if_too_many_files_in_commit(self):
listing = CodeListing(filename='file1.txt', contents=dedent(
"""
file 1 line 1
file 1 line 2
""").lstrip()
)
listing.commit_ref = 'ch17l023'
self._checkout_commit('ch17l022')
with self.assertRaises(ApplyCommitException):
self.sourcetree.apply_listing_from_commit(listing)
示例10: test_happy_with_blank_lines
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_happy_with_blank_lines(self):
listing = CodeListing(filename='file2.txt', contents=dedent(
"""
file 2 line 1 changed
another line changed
""").lstrip()
)
listing.commit_ref = 'ch17l024'
self._checkout_commit('ch17l023')
self.sourcetree.apply_listing_from_commit(listing)
示例11: test_leaves_staging_empty
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_leaves_staging_empty(self):
listing = CodeListing(filename='file1.txt', contents=dedent(
"""
file 1 line 2 amended
file 1 line 3
""").lstrip()
)
listing.commit_ref = 'ch17l021'
self.sourcetree.apply_listing_from_commit(listing)
staged = self.sourcetree.run_command('git diff --staged')
assert staged == ''
示例12: test_handles_indents
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_handles_indents(self):
listing = CodeListing(filename='pythonfile.py', contents=dedent(
"""
def method1(self):
# amend method 1
return 2
[...]
""").lstrip()
)
listing.commit_ref = 'ch17l026'
self._checkout_commit('ch17l025')
self.sourcetree.apply_listing_from_commit(listing)
示例13: test_happy_with_python_callouts
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_happy_with_python_callouts(self):
listing = CodeListing(
filename="file1.txt",
contents=dedent(
"""
[...]
file 1 line 2 amended #
file 1 line 3 #
"""
).lstrip(),
)
listing.commit_ref = "ch17l021"
self.sourcetree.apply_listing_from_commit(listing)
示例14: test_raises_if_listing_line_not_in_after_version
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_raises_if_listing_line_not_in_after_version(self):
listing = CodeListing(filename='file2.txt', contents=dedent(
"""
hello
goodbye
hello
one more line at end
""").lstrip()
)
listing.commit_ref = 'ch17l028'
with self.assertRaises(ApplyCommitException):
self.sourcetree.apply_listing_from_commit(listing)
示例15: test_under_indentation_differences_are_picked_up
# 需要导入模块: from book_parser import CodeListing [as 别名]
# 或者: from book_parser.CodeListing import commit_ref [as 别名]
def test_under_indentation_differences_are_picked_up(self):
listing = CodeListing(filename='pythonfile.py', contents=dedent(
"""
def method1(self):
# amend method 1
return 2
[...]
""").lstrip()
)
listing.commit_ref = 'ch17l026'
self._checkout_commit('ch17l025')
with self.assertRaises(ApplyCommitException):
self.sourcetree.apply_listing_from_commit(listing)