Permalink
Browse files

Demonstrate the leading and trailing slashes in the filename are igno…

…red by FilesystemSynchronousBackend.
  • Loading branch information...
allenap committed Jul 25, 2012
1 parent c76a204 commit e7054bab3be0c0fa8cb7cd073e253a978b7271b5
Showing with 14 additions and 0 deletions.
  1. +14 −0 tftp/test/test_backend.py
View
@@ -54,6 +54,20 @@ def test_insecure_writer(self):
return self.assertFailure(
b.get_writer('../foo'), AccessViolation)
+ @inlineCallbacks
+ def test_read_ignores_leading_and_trailing_slashes(self):
+ b = FilesystemSynchronousBackend(self.temp_dir.path)
+ reader = yield b.get_reader('/dir/foo/')
+ segments_from_root = reader.file_path.segmentsFrom(self.temp_dir)
+ self.assertEqual(["dir", "foo"], segments_from_root)
+
+ @inlineCallbacks
+ def test_write_ignores_leading_and_trailing_slashes(self):
+ b = FilesystemSynchronousBackend(self.temp_dir.path)
+ writer = yield b.get_writer('/dir/bar/')
+ segments_from_root = writer.file_path.segmentsFrom(self.temp_dir)
+ self.assertEqual(["dir", "bar"], segments_from_root)
+
def tearDown(self):
shutil.rmtree(self.temp_dir.path)

0 comments on commit e7054ba

Please sign in to comment.