def test_environment(self):
        """Test the `environment` function."""
        e = cfdm.environment(display=False)
        ep = cfdm.environment(display=False, paths=False)

        self.assertIsInstance(e, list)
        self.assertIsInstance(ep, list)

        components = ["Platform: ", "netCDF4: ", "numpy: ", "cftime: "]
        for component in components:
            self.assertTrue(any(s.startswith(component) for s in e))
            self.assertTrue(any(s.startswith(component) for s in ep))
        for component in [
            "cfdm: {} {}".format(
                cfdm.__version__, os.path.abspath(cfdm.__file__)
            ),
            "Python: {} {}".format(platform.python_version(), sys.executable),
        ]:
            self.assertIn(component, e)
            self.assertNotIn(component, ep)  # paths shouldn't be present here
        for component in [
            "cfdm: {}".format(cfdm.__version__),
            "Python: {}".format(platform.python_version()),
        ]:
            self.assertIn(component, ep)
Beispiel #2
0
    def test_environment(self):
        if self.test_only and inspect.stack()[0][3] not in self.test_only:
            return

        self.assertIsInstance(cfdm.environment(display=False), list)
        self.assertIsInstance(cfdm.environment(display=False, paths=False),
                              list)
        self.assertIsInstance(cfdm.environment(display=False), list)
Beispiel #3
0
    def test_CF_ATOL_RTOL_environment(self):
        if self.test_only and inspect.stack()[0][3] not in self.test_only:
            return

        self.assertTrue(cfdm.CF() == '1.7')

        org = cfdm.RTOL()
        self.assertTrue(cfdm.RTOL(1e-5) == org)
        self.assertTrue(cfdm.RTOL() == 1e-5)
        self.assertTrue(cfdm.RTOL(org) == 1e-5)
        self.assertTrue(cfdm.RTOL() == org)

        org = cfdm.ATOL()
        self.assertTrue(cfdm.ATOL(1e-5) == org)
        self.assertTrue(cfdm.ATOL() == 1e-5)
        self.assertTrue(cfdm.ATOL(org) == 1e-5)
        self.assertTrue(cfdm.ATOL() == org)

        out = cfdm.environment(display=False)
Beispiel #4
0
        self.assertIsInstance(x._del_construct("domainaxis3"), cfdm.DomainAxis)

        # _set_construct
        x = self.c.shallow_copy()
        with self.assertRaises(ValueError):
            x._set_construct(self.f.construct("cellmethod0"),
                             axes=["domainaxis0"])

        # _set_construct_data_axes
        x = self.c.shallow_copy()
        with self.assertRaises(ValueError):
            x._set_construct_data_axes("qwerty", ["domainaxis"])

        with self.assertRaises(ValueError):
            x._set_construct_data_axes("auxiliarycoordinate1", ["qwerty"])

        with self.assertRaises(ValueError):
            x._set_construct_data_axes("auxiliarycoordinate1", ["domainaxis0"])

        # _pop
        x = c.shallow_copy()
        with self.assertRaises(KeyError):
            x._pop("qwerty")


if __name__ == "__main__":
    print("Run date:", datetime.datetime.now())
    cfdm.environment()
    print("")
    unittest.main(verbosity=2)
Beispiel #5
0
        cfdm.write(g, self.tempfilename_parent,
                   external=self.tempfilename_external,
                   verbose=False)

        h = cfdm.read(self.tempfilename_parent, verbose=False)

        self.assertTrue(len(h) == len(parent))

        for i in range(len(h)):
            self.assertTrue(parent[i].equals(h[i], verbose=True))

        h = cfdm.read(self.tempfilename_external)
        external = cfdm.read(self.external_file)

        self.assertTrue(len(h) == len(external))

        for i in range(len(h)):
            self.assertTrue(external[i].equals(h[i], verbose=True))
    #--- End: def        
    
#--- End: class


if __name__ == '__main__':
    print('Run date:', datetime.datetime.utcnow())
    print(cfdm.environment(display=False))
    print()
    unittest.main(verbosity=2)