Skip to content

Commit

Permalink
Skip tests in Python 2 when using Python 3 isms
Browse files Browse the repository at this point in the history
  • Loading branch information
IanLee1521 committed Oct 21, 2017
1 parent 760dc18 commit 905b91f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ def test_without_filename(self):
with smart_open() as fh:
self.assertIs(fh, sys.stdout)

@unittest.skipIf(sys.version_info[0] < 3, 'Python 3 version of test')
def test_with_empty_filename(self):
"""Should raise a `FileNotFoundError`"""
with self.assertRaises(FileNotFoundError):
with smart_open(''):
pass

@unittest.skipIf(sys.version_info[0] >= 3, 'Python 2 version of test')
def test_with_empty_filename_python2(self):
"""Should raise a `FileNotFoundError`"""
with self.assertRaises(IOError):
with smart_open(''):
pass

@unittest.skipIf(sys.version_info[0] < 3, 'Python 3 version of test')
def test_with_real_filename(self):
test_data = 'This is the test data'

Expand Down

0 comments on commit 905b91f

Please sign in to comment.