Skip to content

Commit

Permalink
Use pytest instead of parameterizedtestcase (#657)
Browse files Browse the repository at this point in the history
* Use pytest instead of parameterizedtestcase

The latter is doing weird things in CI, so it's time to get rid of it

https://github.com/RaRe-Technologies/smart_open/pull/652/checks?check_run_id=3733439660

* fix tests

* Update CHANGELOG.md
  • Loading branch information
mpenkov committed Oct 10, 2021
1 parent ff95a3b commit 99cd400
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 160 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,7 @@
# Unreleased

- Use pytest instead of parameterizedtestcase (PR [#657](https://github.com/RaRe-Technologies/smart_open/pull/657), [@mpenkov](https://github.com/mpenkov))

# 5.2.1, 28 August 2021

- make HTTP/S seeking less strict (PR [#646](https://github.com/RaRe-Technologies/smart_open/pull/646), [@mpenkov](https://github.com/mpenkov))
Expand Down
20 changes: 13 additions & 7 deletions integration-tests/test_s3_ported.py
Expand Up @@ -20,7 +20,7 @@
import warnings

import boto3
from parameterizedtestcase import ParameterizedTestCase as PTestCase
import pytest

import smart_open
import smart_open.concurrency
Expand Down Expand Up @@ -277,7 +277,7 @@ def force(multiprocessing=False, concurrent_futures=False):
smart_open.concurrency._CONCURRENT_FUTURES = old_concurrent_futures


class IterBucketTest(PTestCase):
class IterBucketTest(unittest.TestCase):
def setUp(self):
self.expected = [
(key, value)
Expand Down Expand Up @@ -321,11 +321,17 @@ def test_accept_key(self):
self.assertEqual(len(expected), len(actual))
self.assertEqual(expected, sorted(actual))

@PTestCase.parameterize(('workers',), [(x,) for x in (1, 4, 8, 16, 64)])
def test_workers(self, workers):
actual = list(smart_open.s3.iter_bucket(BUCKET_NAME, prefix='iter_bucket', workers=workers))
self.assertEqual(len(self.expected), len(actual))
self.assertEqual(self.expected, sorted(actual))

@pytest.mark.parametrize('workers', [(x,) for x in (1, 4, 8, 16, 64)])
def test_workers(self, workers):
expected = sorted([
(key, value)
for (key, value) in CONTENTS.items()
if key.startswith('iter_bucket/')
])
actual = sorted(smart_open.s3.iter_bucket(BUCKET_NAME, prefix='iter_bucket', workers=workers))
assert len(self.expected) == len(actual)
assert expected == actual


class DownloadKeyTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -35,6 +35,7 @@ def _get_version():
def read(fname):
return io.open(os.path.join(os.path.dirname(__file__), fname), encoding='utf-8').read()


aws_deps = ['boto3']
gcs_deps = ['google-cloud-storage']
azure_deps = ['azure-storage-blob', 'azure-common', 'azure-core']
Expand All @@ -47,7 +48,6 @@ def read(fname):
'responses',
'boto3',
'paramiko',
'parameterizedtestcase',
'pytest',
'pytest-rerunfailures'
]
Expand Down

0 comments on commit 99cd400

Please sign in to comment.