Ejemplo n.º 1
0
    def test_is_evt_from_bytesio(self):
        """
        Test for the is_evt() function from BytesIO objects.
        """
        valid_files = [
            os.path.join(self.path, "BI008_MEMA-04823.evt"),
            os.path.join(self.path, "BX456_MOLA-02351.evt")
        ]
        invalid_files = [os.path.join(self.path, "NOUTF8.evt")]
        py_dir = os.path.join(self.path, os.pardir, os.pardir)
        for filename in os.listdir(py_dir):
            if filename.endswith(".py"):
                invalid_files.append(
                    os.path.abspath(os.path.join(py_dir, filename)))

        for filename in valid_files:
            with open(filename, "rb") as fh:
                buf = io.BytesIO(fh.read())
            buf.seek(0, 0)
            self.assertTrue(is_evt(buf))
            # The is_evt() method should not change the file pointer.
            self.assertEqual(buf.tell(), 0)
        for filename in invalid_files:
            with open(filename, "rb") as fh:
                buf = io.BytesIO(fh.read())
            buf.seek(0, 0)
            self.assertFalse(is_evt(buf))
            # The is_evt() method should not change the file pointer.
            self.assertEqual(buf.tell(), 0)
Ejemplo n.º 2
0
    def test_is_evt_from_bytesio(self):
        """
        Test for the is_evt() function from BytesIO objects.
        """
        valid_files = [os.path.join(self.path, "BI008_MEMA-04823.evt"),
                       os.path.join(self.path, "BX456_MOLA-02351.evt")]
        invalid_files = [os.path.join(self.path, "NOUTF8.evt")]
        py_dir = os.path.join(self.path, os.pardir, os.pardir)
        for filename in os.listdir(py_dir):
            if filename.endswith(".py"):
                invalid_files.append(
                    os.path.abspath(os.path.join(py_dir, filename)))

        for filename in valid_files:
            with open(filename, "rb") as fh:
                buf = io.BytesIO(fh.read())
            buf.seek(0, 0)
            self.assertTrue(is_evt(buf))
            # The is_evt() method should not change the file pointer.
            self.assertEqual(buf.tell(), 0)
        for filename in invalid_files:
            with open(filename, "rb") as fh:
                buf = io.BytesIO(fh.read())
            buf.seek(0, 0)
            self.assertFalse(is_evt(buf))
            # The is_evt() method should not change the file pointer.
            self.assertEqual(buf.tell(), 0)
Ejemplo n.º 3
0
    def test_is_evt(self):
        """
        Test for the is_evt() function.
        """
        valid_files = [os.path.join(self.path, "BI008_MEMA-04823.evt"),
                       os.path.join(self.path, "BX456_MOLA-02351.evt")]
        invalid_files = [os.path.join(self.path, "NOUTF8.evt")]
        py_dir = os.path.join(self.path, os.pardir, os.pardir)
        for filename in os.listdir(py_dir):
            if filename.endswith(".py"):
                invalid_files.append(
                    os.path.abspath(os.path.join(py_dir, filename)))
        self.assertTrue(len(invalid_files) > 0)

        for filename in valid_files:
            self.assertTrue(is_evt(filename))
        for filename in invalid_files:
            self.assertFalse(is_evt(filename))
Ejemplo n.º 4
0
    def test_is_evt(self):
        """
        Test for the is_evt() function.
        """
        valid_files = [
            os.path.join(self.path, "BI008_MEMA-04823.evt"),
            os.path.join(self.path, "BX456_MOLA-02351.evt")
        ]
        invalid_files = [os.path.join(self.path, "NOUTF8.evt")]
        py_dir = os.path.join(self.path, os.pardir, os.pardir)
        for filename in os.listdir(py_dir):
            if filename.endswith(".py"):
                invalid_files.append(
                    os.path.abspath(os.path.join(py_dir, filename)))
        self.assertTrue(len(invalid_files) > 0)

        for filename in valid_files:
            self.assertTrue(is_evt(filename))
        for filename in invalid_files:
            self.assertFalse(is_evt(filename))