Skip to content

Commit e0a7824

Browse 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

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/test_clone.py

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy