diff --git a/ansys/mapdl/reader/archive.py b/ansys/mapdl/reader/archive.py index 7e5f2785..b6eb1158 100644 --- a/ansys/mapdl/reader/archive.py +++ b/ansys/mapdl/reader/archive.py @@ -140,7 +140,7 @@ def __init__(self, filename, read_parameters=False, @property def filename(self) -> str: - """String form of the filename. Accepts ``pathlib.Path`` and string objects when set.""" + """String form of the filename. This property is read-only.""" return str(self._filename) @property @@ -148,10 +148,6 @@ def pathlib_filename(self) -> pathlib.Path: """Return the ``pathlib.Path`` version of the filename. This property can not be set.""" return self._filename - @filename.setter - def filename(self, value: Union[str, pathlib.Path]): - self._filename = pathlib.Path(value) - @property def raw(self): # pragma: no cover raise AttributeError('The `raw` attribute has been depreciated. Access' diff --git a/ansys/mapdl/reader/emat.py b/ansys/mapdl/reader/emat.py index 963fee44..b64c0703 100644 --- a/ansys/mapdl/reader/emat.py +++ b/ansys/mapdl/reader/emat.py @@ -357,7 +357,7 @@ def __init__(self, filename): @property def filename(self): - """String form of the filename. Accepts ``pathlib.Path`` and string objects when set.""" + """String form of the filename. This property is read-only.""" return str(self._filename) @property @@ -365,10 +365,6 @@ def pathlib_filename(self): """Return the ``pathlib.Path`` version of the filename. This property can not be set.""" return self._filename - @filename.setter - def filename(self, value): - self._filename = pathlib.Path(value) - def read_header(self): """Read standard emat file header""" with open(self.pathlib_filename, 'rb') as f: diff --git a/ansys/mapdl/reader/full.py b/ansys/mapdl/reader/full.py index 967b3203..8f4cec7d 100644 --- a/ansys/mapdl/reader/full.py +++ b/ansys/mapdl/reader/full.py @@ -102,7 +102,7 @@ def __init__(self, filename: Union[str, pathlib.Path]): @property def filename(self): - """String form of the filename. Accepts ``pathlib.Path`` and string objects when set.""" + """String form of the filename. This property is read-only.""" return str(self._filename) @property @@ -110,10 +110,6 @@ def pathlib_filename(self): """Return the ``pathlib.Path`` version of the filename. This property can not be set.""" return self._filename - @filename.setter - def filename(self, value): - self._filename = pathlib.Path(value) - @property def k(self): """Stiffness Matrix corresponding to sorted DOF. diff --git a/ansys/mapdl/reader/rst.py b/ansys/mapdl/reader/rst.py index ce8b2436..9e8bac3e 100644 --- a/ansys/mapdl/reader/rst.py +++ b/ansys/mapdl/reader/rst.py @@ -135,7 +135,7 @@ def __init__(self, filename, read_mesh=True, parse_vtk=True, **kwargs): @property def filename(self) -> str: - """String form of the filename. Accepts ``pathlib.Path`` and string objects when set.""" + """String form of the filename. This property is read-only.""" return str(self._filename) @property @@ -143,10 +143,6 @@ def pathlib_filename(self) -> pathlib.Path: """Return the ``pathlib.Path`` version of the filename. This property can not be set.""" return self._filename - @filename.setter - def filename(self, value: Union[str, pathlib.Path]): - self._filename = pathlib.Path(value) - @property def mesh(self): """Mesh from result file. diff --git a/tests/archive/test_archive.py b/tests/archive/test_archive.py index 21475458..f59185d2 100644 --- a/tests/archive/test_archive.py +++ b/tests/archive/test_archive.py @@ -460,11 +460,9 @@ def test_filename_property_is_string(self, pathlib_archive): assert isinstance(a.filename, str) def test_filename_setter_pathlib(self, pathlib_archive): - pathlib_archive.filename = pathlib.Path('dummy2') - assert isinstance(pathlib_archive.filename, str) - assert isinstance(pathlib_archive.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + pathlib_archive.filename = pathlib.Path('dummy2') def test_filename_setter_string(self, pathlib_archive): - pathlib_archive.filename = 'dummy2' - assert isinstance(pathlib_archive.filename, str) - assert isinstance(pathlib_archive.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + pathlib_archive.filename = 'dummy2' diff --git a/tests/test_emat.py b/tests/test_emat.py index abbec3c1..fef130d3 100644 --- a/tests/test_emat.py +++ b/tests/test_emat.py @@ -53,11 +53,10 @@ def test_filename_property_is_string(self, emat_pathlib): assert isinstance(emat_pathlib.filename, str) def test_filename_setter_pathlib(self, emat_pathlib): - emat_pathlib.filename = pathlib.Path('dummy2') - assert isinstance(emat_pathlib.filename, str) - assert isinstance(emat_pathlib.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + emat_pathlib.filename = pathlib.Path('dummy2') def test_filename_setter_string(self, emat_pathlib): - emat_pathlib.filename = 'dummy2' - assert isinstance(emat_pathlib.filename, str) - assert isinstance(emat_pathlib.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + emat_pathlib.filename = 'dummy2' + diff --git a/tests/test_full.py b/tests/test_full.py index 6f3d833d..d651a8f4 100644 --- a/tests/test_full.py +++ b/tests/test_full.py @@ -85,11 +85,9 @@ def test_filename_property_is_string(self, sparse_full_pathlib_full_file): assert isinstance(sparse_full_pathlib_full_file.filename, str) def test_filename_setter_pathlib(self, sparse_full_pathlib_full_file): - sparse_full_pathlib_full_file.filename = pathlib.Path('dummy2') - assert isinstance(sparse_full_pathlib_full_file.filename, str) - assert isinstance(sparse_full_pathlib_full_file.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + sparse_full_pathlib_full_file.filename = pathlib.Path('dummy2') def test_filename_setter_string(self, sparse_full_pathlib_full_file): - sparse_full_pathlib_full_file.filename = 'dummy2' - assert isinstance(sparse_full_pathlib_full_file.filename, str) - assert isinstance(sparse_full_pathlib_full_file.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + sparse_full_pathlib_full_file.filename = 'dummy2' diff --git a/tests/test_rst.py b/tests/test_rst.py index 6263340b..76780caa 100644 --- a/tests/test_rst.py +++ b/tests/test_rst.py @@ -336,17 +336,15 @@ def test_filename_property_is_string(self, pathlib_result): @pytest.mark.skipif(not os.path.isfile(temperature_rst), reason="Requires example files") def test_filename_setter_pathlib(self, pathlib_result): - pathlib_result.filename = pathlib.Path('dummy2') - assert isinstance(pathlib_result.filename, str) - assert isinstance(pathlib_result.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + pathlib_result.filename = pathlib.Path('dummy2') @skip_plotting @pytest.mark.skipif(not os.path.isfile(temperature_rst), reason="Requires example files") def test_filename_setter_string(self, pathlib_result): - pathlib_result.filename = 'dummy2' - assert isinstance(pathlib_result.filename, str) - assert isinstance(pathlib_result.pathlib_filename, pathlib.Path) + with pytest.raises(AttributeError): + pathlib_result.filename = 'dummy2' def test_rst_node_components(hex_rst):