def test_get_dir(): assert get_dir('s3://path/catalog.yml') == 's3://path' assert get_dir('https://example.com/catalog.yml') == 'https://example.com' path = 'example/catalog.yml' assert get_dir(path) == os.path.join(os.getcwd(), os.path.dirname(path)) path = '/example/catalog.yml' assert get_dir(path) == os.path.dirname(path) path = 'example' assert get_dir(path) == os.path.join(os.getcwd(), '')
def test_get_dir(): assert get_dir('file:///path/catalog.yml') == 'file:///path' assert get_dir('https://example.com/catalog.yml') == 'https://example.com' path = 'example/catalog.yml' out = get_dir(path) assert os.path.isabs(out) assert out.endswith('/example/') path = '/example/catalog.yml' out = get_dir(path) # it's ok if the first two chars indicate drive for win (C:) assert '/example/' in [out, out[2:]] path = 'example' out = get_dir(path) assert os.path.isabs(out) assert not out.endswith('/example') assert out.endswith('/')