GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add test for diff with beginning whitespace · gitpython-developers/GitPython@9910a88

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • test_diff.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/test_diff.py‎

Copy file name to clipboardExpand all lines: test/test_diff.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,3 +529,23 @@ def test_diff_patch_with_external_engine(self, rw_dir):
529529
self.assertEqual(len(index_against_head), 1)
530530
index_against_working_tree = repo.index.diff(None, create_patch=True)
531531
self.assertEqual(len(index_against_working_tree), 1)
532+
533+
@with_rw_directory
534+
def test_beginning_space(self, rw_dir):
535+
# Create a file beginning by a whitespace
536+
repo = Repo.init(rw_dir)
537+
file = osp.join(rw_dir, " file.txt")
538+
with open(file, "w") as f:
539+
f.write("hello world")
540+
repo.git.add(Git.polish_url(file))
541+
repo.index.commit("first commit")
542+
543+
# Diff the commit with an empty tree
544+
# and check the paths
545+
diff_index = repo.head.commit.diff(NULL_TREE)
546+
d = diff_index[0]
547+
a_path = d.a_path
548+
b_path = d.b_path
549+
self.assertEqual(a_path, " file.txt")
550+
self.assertEqual(b_path, " file.txt")
551+

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.