summaryrefslogtreecommitdiff
path: root/test/test_clone.py
diff options
context:
space:
mode:
authoryobmod <yobmod@gmail.com>2021-05-03 15:59:07 +0100
committeryobmod <yobmod@gmail.com>2021-05-03 15:59:07 +0100
commit6752fad0e93d1d2747f56be30a52fea212bd15d6 (patch)
treea0618d53d06f35d7326fcacdcaf1832d7ab55b8c /test/test_clone.py
parent2fd9f6ee5c8b4ae4e01a40dc398e2768d838210d (diff)
downloadgitpython-6752fad0e93d1d2747f56be30a52fea212bd15d6.tar.gz
add initial types to remote.py
Diffstat (limited to 'test/test_clone.py')
-rw-r--r--test/test_clone.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_clone.py b/test/test_clone.py
new file mode 100644
index 00000000..e9f6714d
--- /dev/null
+++ b/test/test_clone.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+# This module is part of GitPython and is released under
+# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+
+from pathlib import Path
+import re
+
+import git
+
+from .lib import (
+ TestBase,
+ with_rw_directory,
+)
+
+
+class TestClone(TestBase):
+ @with_rw_directory
+ def test_checkout_in_non_empty_dir(self, rw_dir):
+ non_empty_dir = Path(rw_dir)
+ garbage_file = non_empty_dir / 'not-empty'
+ garbage_file.write_text('Garbage!')
+
+ # Verify that cloning into the non-empty dir fails while complaining about
+ # the target directory not being empty/non-existent
+ try:
+ self.rorepo.clone(non_empty_dir)
+ except git.GitCommandError as exc:
+ self.assertTrue(exc.stderr, "GitCommandError's 'stderr' is unexpectedly empty")
+ expr = re.compile(r'(?is).*\bfatal:\s+destination\s+path\b.*\bexists\b.*\bnot\b.*\bempty\s+directory\b')
+ self.assertTrue(expr.search(exc.stderr), '"%s" does not match "%s"' % (expr.pattern, exc.stderr))
+ else:
+ self.fail("GitCommandError not raised")