# Path: gears/utils.py
# def safe_join(base, *paths):
#     if not os.path.isabs(base):
#         raise ValueError("%r is not an absolute path." % base)
#     base = os.path.normpath(base)
#     path = os.path.normpath(os.path.join(base, *paths))
#     if not path.startswith(base):
#         raise ValueError("Path %r is outside of %r" % (path, base))
#     return path


from gears.utils import safe_join
from unittest2 import TestCase


class SafeJoinTests(TestCase):

    def test_if_base_is_not_absolute(self):
        with self.assertRaisesRegexp(ValueError, 'is not an absolute path'):
            safe_join('assets', 'js/script.js')

    def test_if_path_is_outside_of_base(self):
        with self.assertRaisesRegexp(ValueError, 'is outside of'):
            safe_join('/assets', '../js/script.js')

    def test_success(self):

# Path: gears/utils.py
# def safe_join(base, *paths):
#     if not os.path.isabs(base):
#         raise ValueError("%r is not an absolute path." % base)
#     base = os.path.normpath(base)
#     path = os.path.normpath(os.path.join(base, *paths))
#     if not path.startswith(base):
#         raise ValueError("Path %r is outside of %r" % (path, base))
#     return path


# Path: tests/test_utils.py
from gears.utils import safe_join
from unittest2 import TestCase



class SafeJoinTests(TestCase):

    def test_if_base_is_not_absolute(self):
        with self.assertRaisesRegexp(ValueError, 'is not an absolute path'):
            safe_join('assets', 'js/script.js')

    def test_if_path_is_outside_of_base(self):
        with self.assertRaisesRegexp(ValueError, 'is outside of'):
            safe_join('/assets', '../js/script.js')

    def test_success(self):

        path = safe_join('/assets', 'js/script.js')