ceph/teuthology/test/test_safepath.py
Zack Cerza 589560e6c9 Port from nosetests to py.test
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
2013-10-01 09:07:45 -05:00

56 lines
1.4 KiB
Python

from .. import safepath
class TestSafepath(object):
def test_simple(self):
got = safepath.munge('foo')
assert got == 'foo'
def test_empty(self):
# really odd corner case
got = safepath.munge('')
assert got == '_'
def test_slash(self):
got = safepath.munge('/')
assert got == '_'
def test_slashslash(self):
got = safepath.munge('//')
assert got == '_'
def test_absolute(self):
got = safepath.munge('/evil')
assert got == 'evil'
def test_absolute_subdir(self):
got = safepath.munge('/evil/here')
assert got == 'evil/here'
def test_dot_leading(self):
got = safepath.munge('./foo')
assert got == 'foo'
def test_dot_middle(self):
got = safepath.munge('evil/./foo')
assert got == 'evil/foo'
def test_dot_trailing(self):
got = safepath.munge('evil/foo/.')
assert got == 'evil/foo'
def test_dotdot(self):
got = safepath.munge('../evil/foo')
assert got == '_./evil/foo'
def test_dotdot_subdir(self):
got = safepath.munge('evil/../foo')
assert got == 'evil/_./foo'
def test_hidden(self):
got = safepath.munge('.evil')
assert got == '_evil'
def test_hidden_subdir(self):
got = safepath.munge('foo/.evil')
assert got == 'foo/_evil'