本文整理汇总了Python中book_parser.CodeListing类的典型用法代码示例。如果您正苦于以下问题:Python CodeListing类的具体用法?Python CodeListing怎么用?Python CodeListing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CodeListing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_real_git_stuff
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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)