Skip to content

Commit

Permalink
test: fix TestRepoUtils shared directory creation
Browse files Browse the repository at this point in the history
Signed-off-by: Kyr <[email protected]>
  • Loading branch information
kshtsk committed Feb 11, 2019
1 parent ab7fa3c commit b79b18a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions teuthology/test/test_repo_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pytest import raises, mark
import shutil
import subprocess
import tempfile

from ..exceptions import BranchNotFoundError
from .. import repo_utils
Expand All @@ -12,13 +13,14 @@


class TestRepoUtils(object):
src_path = '/tmp/empty_src'
temp_path = tempfile.mkdtemp(prefix='test_repo', dir='/tmp')
src_path = temp_path + '/empty_src'
# online_repo_url = 'https://github.com/ceph/teuthology.git'
# online_repo_url = 'git://ceph.newdream.net/git/teuthology.git'
online_repo_url = 'https://github.com/ceph/empty.git'
offline_repo_url = 'file://' + src_path
repo_url = None
dest_path = '/tmp/empty_dest'
dest_path = temp_path + '/empty_dest'

@classmethod
def setup_class(cls):
Expand Down Expand Up @@ -55,7 +57,7 @@ def setup_method(self, method):
assert proc.wait() == 0

def teardown_method(self, method):
shutil.rmtree(self.dest_path, ignore_errors=True)
shutil.rmtree(self.temp_path, ignore_errors=True)

def test_clone_repo_existing_branch(self):
repo_utils.clone_repo(self.repo_url, self.dest_path, 'master')
Expand All @@ -67,7 +69,7 @@ def test_clone_repo_non_existing_branch(self):
assert not os.path.exists(self.dest_path)

def test_fetch_no_repo(self):
fake_dest_path = '/tmp/not_a_repo'
fake_dest_path = self.temp_path + '/not_a_repo'
assert not os.path.exists(fake_dest_path)
with raises(OSError):
repo_utils.fetch(fake_dest_path)
Expand All @@ -79,7 +81,7 @@ def test_fetch_noop(self):
assert os.path.exists(self.dest_path)

def test_fetch_branch_no_repo(self):
fake_dest_path = '/tmp/not_a_repo'
fake_dest_path = self.temp_path + '/not_a_repo'
assert not os.path.exists(fake_dest_path)
with raises(OSError):
repo_utils.fetch_branch(fake_dest_path, 'master')
Expand Down

0 comments on commit b79b18a

Please sign in to comment.