lint tests
Lint with [refurb](https://github.com/dosisod/refurb) using `--disable 126 --python-version 3.9` Also update bats to 1.8.2 and bats-assets to 2.1.0. No changes to the tests, all still passing.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[pytest]
|
||||
addopts = --strict-markers
|
||||
markers =
|
||||
online: tests require a connection to the internet
|
||||
reddit: tests require a connection to Reddit
|
||||
slow: test is slow to run
|
||||
authenticated: test requires an authenticated Reddit instance
|
||||
|
||||
|
||||
Submodule scripts/tests/bats updated: ce5ca2802f...e8c840b58f
Submodule scripts/tests/test_helper/bats-assert updated: e0de84e9c0...78fa631d13
@@ -47,7 +47,7 @@ def assert_all_results_are_submissions(result_limit: int, results: list[Iterator
|
||||
|
||||
def assert_all_results_are_submissions_or_comments(result_limit: int, results: list[Iterator]) -> list:
|
||||
results = [sub for res in results for sub in res]
|
||||
assert all([isinstance(res, praw.models.Submission) or isinstance(res, praw.models.Comment) for res in results])
|
||||
assert all([isinstance(res, (praw.models.Submission, praw.models.Comment)) for res in results])
|
||||
assert not any([isinstance(m, MagicMock) for m in results])
|
||||
if result_limit is not None:
|
||||
assert len(results) == result_limit
|
||||
@@ -259,7 +259,7 @@ def test_get_subreddit_search(
|
||||
assert all([res.subreddit.display_name in test_subreddits for res in results])
|
||||
assert len(results) <= max_expected_len
|
||||
if max_expected_len != 0:
|
||||
assert len(results) > 0
|
||||
assert results
|
||||
assert not any([isinstance(m, MagicMock) for m in results])
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ def test_get_subscribed_subreddits(downloader_mock: MagicMock, authenticated_red
|
||||
downloader_mock.sort_filter = RedditTypes.SortType.HOT
|
||||
results = RedditConnector.get_subreddits(downloader_mock)
|
||||
assert all([isinstance(s, praw.models.ListingGenerator) for s in results])
|
||||
assert len(results) > 0
|
||||
assert results
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('test_name', 'expected'), (
|
||||
|
||||
@@ -152,7 +152,7 @@ def test_download_submission_hash_exists(
|
||||
RedditDownloader._download_submission(downloader_mock, submission)
|
||||
folder_contents = list(tmp_path.iterdir())
|
||||
output = capsys.readouterr()
|
||||
assert len(folder_contents) == 0
|
||||
assert not folder_contents
|
||||
assert re.search(r'Resource hash .*? downloaded elsewhere', output.out)
|
||||
|
||||
|
||||
|
||||
@@ -66,6 +66,6 @@ def test_token_manager_write(example_config: configparser.ConfigParser, tmp_path
|
||||
test_manager = OAuth2TokenManager(example_config, test_path)
|
||||
test_manager.post_refresh_callback(mock_authoriser)
|
||||
assert example_config.get('DEFAULT', 'user_token') == 'changed_token'
|
||||
with open(test_path, 'r') as file:
|
||||
with test_path.open('r') as file:
|
||||
file_contents = file.read()
|
||||
assert 'user_token = changed_token' in file_contents
|
||||
|
||||
Reference in New Issue
Block a user