Repository: pydicom/pydicom

Issue:
DeferredDataElement deprecation
I've been looking through the code in `dataelem.py` and noticed that `DeferredDataElement` seems to be broken. The `value` getter calls `self.read_value()` which doesn't exist, as far as I can tell. The class doesn't seem to be used anywhere, doesn't have test coverage and hasn't changed since you moved to github, so I was wondering if it's still supported or if it should be removed?

Discussion:
darcymason: Looks good.  Reminder that this requires #139 to be in place for v1.2 (already labeled as such).

Patch:
diff --git a/doc/whatsnew/v1.2.0.rst b/doc/whatsnew/v1.2.0.rst
index 0def5e071..40f6b0a47 100644
--- a/doc/whatsnew/v1.2.0.rst
+++ b/doc/whatsnew/v1.2.0.rst
@@ -4,6 +4,9 @@ Version 1.2.0
 Changelog
 ---------
 
+* ``DeferredDataElement`` class deprecated and will be removed in v1.3
+  (:issue:`291`)
+
 Fixes
 .....
 
diff --git a/pydicom/dataelem.py b/pydicom/dataelem.py
index 2b0c6dd01..1c4e8e4a9 100644
--- a/pydicom/dataelem.py
+++ b/pydicom/dataelem.py
@@ -13,6 +13,7 @@ A DataElement has a tag,
 #
 from __future__ import absolute_import
 from collections import namedtuple
+import warnings
 
 from pydicom import config  # don't import datetime_conversion directly
 from pydicom import compat
@@ -400,6 +401,12 @@ class DeferredDataElement(DataElement):
         data_element_tell -- file position at start of data element,
            (not the start of the value part, but start of whole element)
         """
+        warnings.warn(
+            "DeferredDataElement is deprecated and will be removed in "
+            "pydicom v1.3",
+            DeprecationWarning
+        )
+
         if not isinstance(tag, BaseTag):
             tag = Tag(tag)
         self.tag = tag


Test patch:
diff --git a/pydicom/tests/test_dataelem.py b/pydicom/tests/test_dataelem.py
index ce233a548..f39ca068d 100644
--- a/pydicom/tests/test_dataelem.py
+++ b/pydicom/tests/test_dataelem.py
@@ -13,9 +13,15 @@ import unittest
 import pytest
 
 from pydicom.charset import default_encoding
-from pydicom.dataelem import (DataElement, RawDataElement,
-                              DataElement_from_raw, isStringOrStringList)
+from pydicom.dataelem import (
+    DataElement,
+    RawDataElement,
+    DataElement_from_raw,
+    isStringOrStringList,
+    DeferredDataElement
+)
 from pydicom.dataset import Dataset
+from pydicom.filebase import DicomBytesIO
 from pydicom.tag import Tag
 from pydicom.uid import UID
 from pydicom.valuerep import DSfloat
@@ -375,5 +381,10 @@ class RawDataElementTests(unittest.TestCase):
             DataElement_from_raw(raw, default_encoding)
 
 
-if __name__ == "__main__":
-    unittest.main()
+def test_deferred_data_element_deprecated():
+    """Test the deprecation warning is working"""
+    fp = DicomBytesIO()
+    fp.is_little_endian = True
+    fp.is_implicit_VR = True
+    with pytest.deprecated_call():
+        elem = DeferredDataElement(0x00000000, 'UL', fp, 0, 0, 4)