def test_program_warn(self, tmpdir, mutation): params = self.gen_params(keypair=mutation, restart=False) with tmpdir.as_cwd(): self.create_ncdf(params) with pytest.warns(UserWarning) as record: NCDFReader(params['filename']) assert len(record) == 1 wmsg = ("NCDF trajectory test.nc may not fully adhere to AMBER " "standards as either the `program` or `programVersion` " "attributes are missing") assert str(record[0].message.args[0]) == wmsg
def test_conventionversion_warn(self, tmpdir): mutation = {'ConventionVersion': '2.0'} params = self.gen_params(keypair=mutation, restart=False) with tmpdir.as_cwd(): self.create_ncdf(params) with pytest.warns(UserWarning) as record: NCDFReader(params['filename']) assert len(record) == 1 wmsg = ("NCDF trajectory format is 2.0 but the reader " "implements format 1.0") assert str(record[0].message.args[0]) == wmsg
def test_degrees_warn(self, tmpdir): """Checks that plural degrees throws an user deprecation warning TODO: remove in MDAnalysis version 1.0 (Issue #2327)""" mutation = {'cell_angles': 'degrees'} params = self.gen_params(keypair=mutation, restart=False) with tmpdir.as_cwd(): self.create_ncdf(params) with pytest.warns(DeprecationWarning) as record: NCDFReader(params['filename']) assert len(record) == 1 wmsg = ("DEPRECATED (1.0): NCDF trajectory {0} uses units of " "`degrees` for the `cell_angles` variable instead of " "`degree`. Support for non-AMBER convention units is " "now deprecated and will end in MDAnalysis version 1.0. " "Afterwards, reading this file will raise an error.") assert str(record[0].message.args[0]) == wmsg
def test_import_netcdfreader(self): # do it here because netcdf isn't required from MDAnalysis.coordinates.TRJ import NCDFReader # Check the error meessage that we're giving out try: rd = NCDFReader('myfile.ncdf', n_atoms=100) except ImportError as e: assert_('netCDF4 package missing' in e.args[0]) assert_('See installation instructions at' in e.args[0]) else: # fail if we don't get importerror raise AssertionError finally: try: os.unlink('myfile.ncdf') except OSError: pass
def test_verify_units_errors(self, evaluate, expected): """Directly tests expected failures of _verify_units""" with pytest.raises(NotImplementedError): NCDFReader._verify_units(evaluate.encode('utf-8'), expected)
def test_notimplemented_errors(self, tmpdir, mutation): params = self.gen_params(keypair=mutation, restart=False) with tmpdir.as_cwd(): self.create_ncdf(params) with pytest.raises(NotImplementedError): NCDFReader(params['filename'])