Пример #1
0
    def test_eq_subclass(self):
        class Subclass(mount.Mount):
            pass

        m1 = mount.Mount("spec", "file")
        m2 = Subclass("spec", "file")
        self.assertFalse(m1 == m2, "%s should not equal %s" % (m1, m2))
Пример #2
0
    def test_subclass_different_hash(self):
        class Subclass(mount.Mount):
            pass

        m1 = mount.Mount("spec", "file")
        m2 = Subclass("spec", "file")
        self.assertNotEqual(hash(m1), hash(m2))
Пример #3
0
 def testLoopMount(self):
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     with namedTemporaryDir() as mpath:
         # two nested with blocks to be python 2.6 friendly
         with createFloppyImage(FLOPPY_SIZE) as path:
             m = mount.Mount(path, mpath)
             m.mount(mntOpts="loop")
             try:
                 self.assertTrue(m.isMounted())
             finally:
                 m.umount()
Пример #4
0
 def testLoopMount(self):
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     mpath = mkdtemp()
     with createFloppyImage(FLOPPY_SIZE) as path:
         m = mount.Mount(path, mpath)
         m.mount(mntOpts="loop")
         try:
             self.assertTrue(m.isMounted())
         finally:
             m.umount()
             shutil.rmtree(mpath)
Пример #5
0
 def testLoopMount(self):
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     with namedTemporaryDir() as mpath:
         # two nested with blocks to be python 2.6 friendly
         with createFloppyImage(FLOPPY_SIZE) as path:
             m = mount.Mount(path, mpath)
             m.mount(mntOpts="loop")
             try:
                 self.assertTrue(m.isMounted())
             finally:
                 m.umount(force=True, freeloop=True)
                 # TODO: Use libudev to wait for specific event
                 with stopwatch("Wait for udev events"):
                     udevadm.settle(5)
Пример #6
0
 def testSymlinkMount(self):
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     with namedTemporaryDir() as root_dir:
         backing_image = os.path.join(root_dir, 'backing.img')
         link_to_image = os.path.join(root_dir, 'link_to_image')
         mountpoint = os.path.join(root_dir, 'mountpoint')
         with open(backing_image, 'w') as f:
             os.ftruncate(f.fileno(), 1024**3)
         rc, out, err = execCmd(['/sbin/mkfs.ext2', "-F", backing_image],
                                raw=True)
         if rc != 0:
             raise RuntimeError("Error creating filesystem: %s" % err)
         os.symlink(backing_image, link_to_image)
         os.mkdir(mountpoint)
         m = mount.Mount(link_to_image, mountpoint)
         m.mount(mntOpts="loop")
         try:
             self.assertTrue(m.isMounted())
         finally:
             m.umount()
Пример #7
0
 def test_equal_same_hash(self):
     m1 = mount.Mount("spec", "file")
     m2 = mount.Mount("spec", "file")
     self.assertEqual(hash(m1), hash(m2))
Пример #8
0
 def test_ne_equal(self):
     m1 = mount.Mount("spec", "file")
     m2 = mount.Mount("spec", "file")
     self.assertFalse(m1 != m2, "%s should equal %s" % (m1, m2))
Пример #9
0
 def test_eq_different(self, spec1, spec2, file1, file2):
     m1 = mount.Mount(spec1, file1)
     m2 = mount.Mount(spec2, file2)
     self.assertFalse(m1 == m2, "%s should not equal %s" % (m1, m2))
Пример #10
0
 def test_eq_equal(self):
     m1 = mount.Mount("spec", "file")
     m2 = mount.Mount("spec", "file")
     self.assertTrue(m1 == m2, "%s should equal %s" % (m1, m2))
Пример #11
0
 def test_not_equal_different_hash(self, spec1, spec2, file1, file2):
     m1 = mount.Mount(spec1, file1)
     m2 = mount.Mount(spec2, file2)
     self.assertNotEqual(hash(m1), hash(m2))