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

Appearance settings

Commit e0a7824

Browse filesBrowse files
muggenhorByron
authored andcommitted
test(clone): verify stderr for a failing clone into a non-empty dir
Addresses #1221, #1223
1 parent 36440f7 commit e0a7824
Copy full SHA for e0a7824

1 file changed

+30Lines changed: 30 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/test_clone.py‎

Copy file name to clipboard
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
# This module is part of GitPython and is released under
3+
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
4+
5+
from pathlib import Path
6+
import re
7+
8+
import git
9+
10+
from .lib import (
11+
TestBase,
12+
with_rw_directory,
13+
)
14+
15+
class TestClone(TestBase):
16+
@with_rw_directory
17+
def test_checkout_in_non_empty_dir(self, rw_dir):
18+
non_empty_dir = Path(rw_dir)
19+
garbage_file = non_empty_dir / 'not-empty'
20+
garbage_file.write_text('Garbage!')
21+
22+
# Verify that cloning into the non-empty dir fails while complaining about the target directory not being empty/non-existent
23+
try:
24+
self.rorepo.clone(non_empty_dir)
25+
except git.GitCommandError as exc:
26+
self.assertTrue(exc.stderr, "GitCommandError's 'stderr' is unexpectedly empty")
27+
expr = re.compile(r'(?is).*\bfatal:\s+destination\s+path\b.*\bexists\b.*\bnot\b.*\bempty\s+directory\b')
28+
self.assertTrue(expr.search(exc.stderr), '"%s" does not match "%s"' % (expr.pattern, exc.stderr))
29+
else:
30+
self.fail("GitCommandError not raised")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.