# Path: ocbpy/instruments/general.py
# def test_file(filename):
# def load_ascii_data(filename, hlines, gft_kwargs=dict(), hsplit=None,
#                     datetime_cols=list(), datetime_fmt=None, int_cols=list(),
#                     str_cols=list(), max_str_length=50, header=list()):


import datetime as dt
import numpy as np
import os
import platform
import unittest
    import filecmp
import ocbpy
import ocbpy.instruments.supermag as ocb_ismag
from sys import version_info
from ocbpy.instruments import general
                                         ocbfile=self.test_ocb)

    @unittest.skipIf(version_info.major > 2,
                     'Python 2.7 does not support subTest')
    def test_supermag2ascii_ocb_bad_input(self):
        """ Test the failure when a bad SuperMAG file is input
        """
        with self.assertRaisesRegex(IOError, "SuperMAG file cannot be opened"):
            ocb_ismag.supermag2ascii_ocb("fake_file", "fake_out",
                                         ocbfile=self.test_ocb)

    @unittest.skipIf(version_info.major < 3,
                     'Already tested, remove in 2020')
    def test_supermag2ascii_ioerr_messages(self):
        """ Test the failures that produce reliable IOError messages
        """
        for val in [("SuperMAG file cannot be opened",
                     ["fake_file", "fake_out"]),
                    ("output filename is not a string", [self.test_file, 1])]:
            with self.subTest(val=val):
                with self.assertRaisesRegex(IOError, val[0]):
                    ocb_ismag.supermag2ascii_ocb(*val[1],
                                                 ocbfile=self.test_ocb)

    def test_supermag2ascii_ocb_bad_ocb(self):
        """ Test the SuperMAG conversion with a bad ocb file """
        ocb_ismag.supermag2ascii_ocb(self.test_file, "fake_out",
                                     ocbfile="fake_ocb", hemisphere=1)

        # Compare created file to stored test file

# Path: ocbpy/instruments/general.py
# def test_file(filename):
# def load_ascii_data(filename, hlines, gft_kwargs=dict(), hsplit=None,
#                     datetime_cols=list(), datetime_fmt=None, int_cols=list(),
#                     str_cols=list(), max_str_length=50, header=list()):


# Path: ocbpy/tests/test_supermag.py
import datetime as dt
import numpy as np
import os
import platform
import unittest
    import filecmp
import ocbpy
import ocbpy.instruments.supermag as ocb_ismag
from sys import version_info
from ocbpy.instruments import general

                                         ocbfile=self.test_ocb)

    @unittest.skipIf(version_info.major > 2,
                     'Python 2.7 does not support subTest')
    def test_supermag2ascii_ocb_bad_input(self):
        """ Test the failure when a bad SuperMAG file is input
        """
        with self.assertRaisesRegex(IOError, "SuperMAG file cannot be opened"):
            ocb_ismag.supermag2ascii_ocb("fake_file", "fake_out",
                                         ocbfile=self.test_ocb)

    @unittest.skipIf(version_info.major < 3,
                     'Already tested, remove in 2020')
    def test_supermag2ascii_ioerr_messages(self):
        """ Test the failures that produce reliable IOError messages
        """
        for val in [("SuperMAG file cannot be opened",
                     ["fake_file", "fake_out"]),
                    ("output filename is not a string", [self.test_file, 1])]:
            with self.subTest(val=val):
                with self.assertRaisesRegex(IOError, val[0]):
                    ocb_ismag.supermag2ascii_ocb(*val[1],
                                                 ocbfile=self.test_ocb)

    def test_supermag2ascii_ocb_bad_ocb(self):
        """ Test the SuperMAG conversion with a bad ocb file """
        ocb_ismag.supermag2ascii_ocb(self.test_file, "fake_out",
                                     ocbfile="fake_ocb", hemisphere=1)

        # Compare created file to stored test file

        self.assertFalse(general.test_file("fake_out"))