From b2696813717e2bb4a9e7fe87937ffd8ccb76ed33 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Thu, 22 Apr 2021 10:29:38 +0200 Subject: [PATCH 1/2] test(clone): verify stderr for a failing clone into a non-empty dir Addresses #1221, #1223 --- test/test_clone.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/test_clone.py diff --git a/test/test_clone.py b/test/test_clone.py new file mode 100644 index 000000000..e4eb9fe13 --- /dev/null +++ b/test/test_clone.py @@ -0,0 +1,30 @@ +# -*- 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") From 86c01a22047e7bb86c3c72a4aa82e04309a54d63 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 22 Apr 2021 16:45:15 +0800 Subject: [PATCH 2/2] fix flake --- test/test_clone.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_clone.py b/test/test_clone.py index e4eb9fe13..e9f6714d3 100644 --- a/test/test_clone.py +++ b/test/test_clone.py @@ -12,6 +12,7 @@ with_rw_directory, ) + class TestClone(TestBase): @with_rw_directory def test_checkout_in_non_empty_dir(self, rw_dir): @@ -19,7 +20,8 @@ def test_checkout_in_non_empty_dir(self, 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 + # 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: 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