Skip to content

Commit

Permalink
Add tests for get_compression
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w committed Dec 31, 2018
1 parent a670830 commit 7184c59
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_xtarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tempfile import mkstemp
from unittest import TestCase

from xtarfile.xtarfile import get_compression
from xtarfile.xtarfile import xtarfile_open
from xtarfile.xtarfile import HANDLERS

Expand Down Expand Up @@ -41,6 +42,16 @@ def mode(self, mode):
return '{}|{}'.format(mode, self.compressor)


class GetCompressionTests(TestCase):
def test_prefers_explicit_open_mode(self):
compression = get_compression('foo.tar.gz', 'r:bz2')
self.assertEqual(compression, 'bz2')

def test_falls_back_to_extension(self):
compression = get_compression('foo.tar.gz', 'r')
self.assertEqual(compression, 'gz')


class OpenTests(TestCase):
def test_roundtrip(self):
plugins = [key for (key, value) in HANDLERS.items() if value]
Expand Down

0 comments on commit 7184c59

Please sign in to comment.