diff --git a/apachedex/__init__.py b/apachedex/__init__.py
index bcede95b7bf880a4fe8dbafb5144a3822c1e6483..3484c53e05b40f44cb5b3211fba3314159fbbb26 100755
--- a/apachedex/__init__.py
+++ b/apachedex/__init__.py
@@ -83,6 +83,7 @@ def _wrapOpen(func):
 gzip_open = gzip.open
 if sys.version_info >= (3, 3):
   import lzma
+  lzma_open = lzma.open
   bz2_open = bz2.open
   _read_mode = 'rt'
 else:
@@ -91,6 +92,7 @@ else:
   _read_mode = 'r'
   try:
     from backports import lzma
+    lzma_open = _wrapOpen(lzma.open)
   except ImportError:
     lzma = None
 
@@ -99,7 +101,7 @@ FILE_OPENER_LIST = [
   (bz2_open, IOError),
 ]
 if lzma is not None:
-  FILE_OPENER_LIST.append((lzma.open, lzma.LZMAError))
+  FILE_OPENER_LIST.append((lzma_open, lzma.LZMAError))
 
 # XXX: what encoding ? apache doesn't document one, but requests are supposed
 # to be urlencoded, so pure ascii. Are timestamps localised ?
diff --git a/apachedex/tests.py b/apachedex/tests.py
index 41ebffefe4bd10cb0c9e1a45dee8a5f8167c22cb..dd20ccd0c45ab0dabd8840eea21215715b5c3454 100644
--- a/apachedex/tests.py
+++ b/apachedex/tests.py
@@ -6,6 +6,7 @@ import gzip
 from StringIO import StringIO
 import tempfile
 import apachedex
+from . import lzma
 
 
 class ApacheDEXTestCase(unittest.TestCase):
@@ -89,3 +90,13 @@ class TestZlibEncoding(ApacheDEXTestCase, EncodedInputTestMixin):
     with gzip.GzipFile(mode="w", fileobj=f) as gzfile:
       gzfile.write(self.DEFAULT_LINE)
     return f.getvalue()
+
+
+if lzma is not None:
+  class TestLzmaEncoding(ApacheDEXTestCase, EncodedInputTestMixin):
+    def _getInputData(self):
+      return lzma.compress(self.DEFAULT_LINE)
+else:
+  class TestLzmaEncoding(ApacheDEXTestCase):
+    def test(self):
+      self.skipTest("lzma not available")