Пример #1
0
class TestFile(unittest.TestCase):
    def setUp(self):
        self.l4kernel = File("data/arm_exec", "rb")

    def test_stat(self):
        self.l4kernel.stat()

    def test_inode(self):
        self.l4kernel.inode()

    def test_device(self):
        self.l4kernel.device()

    def test_num_links(self):
        links = self.l4kernel.num_links()
        self.assertEqual(links, 1)

    def test_uid(self):
        self.l4kernel.uid()

    def test_gid(self):
        self.l4kernel.gid()

    def test_size(self):
        size = self.l4kernel.size()
        self.assertEqual(size, 1306358)

    def test_atime(self):
        self.l4kernel.atime()

    def test_mtime(self):
        self.l4kernel.mtime()

    def test_ctime(self):
        """Test that ctime() work. This only checks it runs without
        errors, not the value."""
        self.l4kernel.ctime()

    def test_isdir(self):
        """Test the is_dir() method."""
        self.assertEqual(self.l4kernel.is_dir(), False)

    def test_ischaracter(self):
        """Test the is_character() method."""
        self.assertEqual(self.l4kernel.is_character(), False)

    def test_isblock(self):
        """Test the is_block() method."""
        self.assertEqual(self.l4kernel.is_block(), False)

    def test_isdevice(self):
        """Test the is_device() method."""
        self.assertEqual(self.l4kernel.is_device(), False)

    def test_regular(self):
        """Test the is_regular() method."""
        self.assertEqual(self.l4kernel.is_regular(), True)

    def test_isfifo(self):
        """Test the is_fifo() method."""
        self.assertEqual(self.l4kernel.is_fifo(), False)

    def test_issymlink(self):
        """Test the is_symlink() method."""
        self.assertEqual(self.l4kernel.is_symlink(), False)

    def test_issocket(self):
        """Test the is_socket() method."""
        self.assertEqual(self.l4kernel.is_socket(), False)

    def test_getdata(self):
        """Test the get_data() method."""
        self.assertEqual(len(self.l4kernel.get_data(0, 10)), 10)
        self.assertRaises(EOFError, self.l4kernel.get_data, 0,
                          self.l4kernel.size() + 1)
        self.assertRaises(IOError, self.l4kernel.get_data, -1, 0)
Пример #2
0
class TestFile(unittest.TestCase):
    def setUp(self):
        self.l4kernel = File("data/arm_exec", "rb")
    
    def test_stat(self):
        self.l4kernel.stat()

    def test_inode(self):
        self.l4kernel.inode()

    def test_device(self):
        self.l4kernel.device()

    def test_num_links(self):
        links = self.l4kernel.num_links()
        self.assertEqual(links, 1)

    def test_uid(self):
        self.l4kernel.uid()

    def test_gid(self):
        self.l4kernel.gid()

    def test_size(self):
        size = self.l4kernel.size()
        self.assertEqual(size, 1306358)

    def test_atime(self):
        self.l4kernel.atime()

    def test_mtime(self):
        self.l4kernel.mtime()

    def test_ctime(self):
        """Test that ctime() work. This only checks it runs without
        errors, not the value."""
        self.l4kernel.ctime()

    def test_isdir(self):
        """Test the is_dir() method."""
        self.assertEqual(self.l4kernel.is_dir(), False)

    def test_ischaracter(self):
        """Test the is_character() method."""
        self.assertEqual(self.l4kernel.is_character(), False)

    def test_isblock(self):
        """Test the is_block() method."""
        self.assertEqual(self.l4kernel.is_block(), False)

    def test_isdevice(self):
        """Test the is_device() method."""
        self.assertEqual(self.l4kernel.is_device(), False)

    def test_regular(self):
        """Test the is_regular() method."""
        self.assertEqual(self.l4kernel.is_regular(), True)

    def test_isfifo(self):
        """Test the is_fifo() method."""
        self.assertEqual(self.l4kernel.is_fifo(), False)

    def test_issymlink(self):
        """Test the is_symlink() method."""
        self.assertEqual(self.l4kernel.is_symlink(), False)

    def test_issocket(self):
        """Test the is_socket() method."""
        self.assertEqual(self.l4kernel.is_socket(), False)

    def test_getdata(self):
        """Test the get_data() method."""
        self.assertEqual(len(self.l4kernel.get_data(0, 10)), 10)
        self.assertRaises(EOFError, self.l4kernel.get_data,
                          0, self.l4kernel.size() + 1)
        self.assertRaises(IOError, self.l4kernel.get_data, -1, 0)