Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to work with moto 5.0.0 and pytest 8.0.0 #923

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
* Set Content-Bbox and Content-Crs headers in the HTTP response
* Support safe CURIE syntax for CRS specification

### Fixes

* Make S3 unit tests compatible with moto 5 server (#922)
* Make some CLI unit tests compatible with pytest 8 (#922)

### Other changes

* Require Python >=3.9 (previously >=3.8)
Expand Down
14 changes: 10 additions & 4 deletions test/cli/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,25 @@ def setUp(self):
@command(name='test_warnings')
def test_warnings():
warnings.warn(self.USER_WARNING_MESSAGE)
warnings.warn(self.DEPRECATION_WARNING_MESSAGE, category=DeprecationWarning)
warnings.warn(self.RUNTIME_WARNING_MESSAGE, category=RuntimeWarning)
warnings.warn(
self.DEPRECATION_WARNING_MESSAGE, category=DeprecationWarning
)
warnings.warn(
self.RUNTIME_WARNING_MESSAGE, category=RuntimeWarning
)

xcube.cli.main.cli.add_command(test_warnings)

def test_warnings_not_issued_by_default(self):
with pytest.warns(None) as record:
with pytest.warns(UserWarning) as record:
self.invoke_cli(['test_warnings'])
self.assertEqual(['This is a user warning.'],
list(map(lambda r: str(r.message), record.list)))

def test_warnings_issued_when_enabled(self):
with pytest.warns(None) as record:
with pytest.warns(
(UserWarning, DeprecationWarning, RuntimeWarning)
) as record:
self.invoke_cli(['--warnings', 'test_warnings'])
self.assertEqual(['This is a user warning.',
'This is a deprecation warning.',
Expand Down
2 changes: 1 addition & 1 deletion test/s3test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MOTO_SERVER_ENDPOINT_URL = f'http://127.0.0.1:5000'

MOTOSERVER_PATH = moto.server.__file__
MOTOSERVER_ARGS = [sys.executable, MOTOSERVER_PATH, 's3']
MOTOSERVER_ARGS = [sys.executable, MOTOSERVER_PATH]


class S3Test(unittest.TestCase):
Expand Down
Loading