2012-09-09 21:07:04 +02:00
|
|
|
import os
|
|
|
|
|
2012-09-07 22:49:22 +02:00
|
|
|
from django.utils import unittest
|
|
|
|
from django.utils._os import safe_join
|
|
|
|
|
|
|
|
|
|
|
|
class SafeJoinTests(unittest.TestCase):
|
|
|
|
def test_base_path_ends_with_sep(self):
|
2012-09-09 21:07:04 +02:00
|
|
|
drive, path = os.path.splitdrive(safe_join("/abc/", "abc"))
|
2012-09-07 22:49:22 +02:00
|
|
|
self.assertEqual(
|
2012-09-09 21:07:04 +02:00
|
|
|
path,
|
|
|
|
"{0}abc{0}abc".format(os.path.sep)
|
2012-09-07 22:49:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_root_path(self):
|
2012-09-09 21:07:04 +02:00
|
|
|
drive, path = os.path.splitdrive(safe_join("/", "path"))
|
2012-09-07 22:49:22 +02:00
|
|
|
self.assertEqual(
|
2012-09-09 21:07:04 +02:00
|
|
|
path,
|
|
|
|
"{0}path".format(os.path.sep),
|
2012-09-07 22:49:22 +02:00
|
|
|
)
|
|
|
|
|
2012-09-09 21:07:04 +02:00
|
|
|
drive, path = os.path.splitdrive(safe_join("/", ""))
|
2012-09-07 22:49:22 +02:00
|
|
|
self.assertEqual(
|
2012-09-09 21:07:04 +02:00
|
|
|
path,
|
|
|
|
os.path.sep,
|
2012-09-07 22:49:22 +02:00
|
|
|
)
|