Exemple #1
0
def test_is_repo():
    try:
        tmpdir = tempfile.mkdtemp(prefix='nbdime-test')
        subdir = tempfile.mkdtemp(dir=tmpdir)
        subfile = tempfile.NamedTemporaryFile(dir=tmpdir)
        subsubfile = tempfile.NamedTemporaryFile(dir=subdir)
        with subfile, subsubfile:
            assert False == is_in_repo(tmpdir)
            assert False == is_in_repo(subdir)
            assert False == is_in_repo(subfile.name)
            assert False == is_in_repo(subsubfile.name)
            os.makedirs(os.path.join(subdir, '.git'))
            assert False == is_in_repo(tmpdir)
            assert True == is_in_repo(subdir)
            assert False == is_in_repo(subfile.name)
            assert True == is_in_repo(subsubfile.name)
            os.makedirs(os.path.join(tmpdir, '.git'))
            assert True == is_in_repo(tmpdir)
            assert True == is_in_repo(subdir)
            assert True == is_in_repo(subfile.name)
            assert True == is_in_repo(subsubfile.name)

    finally:
        shutil.rmtree(tmpdir)
Exemple #2
0
def test_is_repo():
    try:
        tmpdir = tempfile.mkdtemp(prefix='nbdime-test')
        subdir = tempfile.mkdtemp(dir=tmpdir)
        subfile = tempfile.NamedTemporaryFile(dir=tmpdir)
        subsubfile = tempfile.NamedTemporaryFile(dir=subdir)
        with subfile, subsubfile:
            assert False == is_in_repo(tmpdir)
            assert False == is_in_repo(subdir)
            assert False == is_in_repo(subfile.name)
            assert False == is_in_repo(subsubfile.name)
            os.makedirs(os.path.join(subdir, '.git'))
            assert False == is_in_repo(tmpdir)
            assert True == is_in_repo(subdir)
            assert False == is_in_repo(subfile.name)
            assert True == is_in_repo(subsubfile.name)
            os.makedirs(os.path.join(tmpdir, '.git'))
            assert True == is_in_repo(tmpdir)
            assert True == is_in_repo(subdir)
            assert True == is_in_repo(subfile.name)
            assert True == is_in_repo(subsubfile.name)

    finally:
        shutil.rmtree(tmpdir)