Skip to content

Commit

Permalink
Tests: Fix remaining warnings (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber authored Oct 26, 2022
1 parent ebbf17a commit b5d1fbe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ minversion = '6.0'
testpaths = [
'test',
]
filterwarnings = [
'ignore::DeprecationWarning:frozendict:',
]
filterwarnings = []

[tool.yapf]
align_closing_bracket_with_visual_indent = true
Expand Down
2 changes: 1 addition & 1 deletion test/test_process_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_validator(self):
"""Test the port validator with default."""

def dict_validator(dictionary, port):
if 'key' not in dictionary or dictionary['key'] is not 'value':
if 'key' not in dictionary or dictionary['key'] != 'value':
return 'Invalid dictionary'

self.spec.input('dict', default={'key': 'value'}, validator=dict_validator)
Expand Down
28 changes: 15 additions & 13 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@
import asyncio
import functools
import inspect
import unittest
import warnings

import pytest

from plumpy.utils import AttributesFrozendict, ensure_coroutine, load_function


class TestAttributesFrozendict(unittest.TestCase):
class TestAttributesFrozendict:

def test_getitem(self):
d = AttributesFrozendict({'a': 5})
self.assertEqual(d['a'], 5)
assert d['a'] == 5

with self.assertRaises(KeyError):
with pytest.raises(KeyError):
d['b']

def test_getattr(self):
d = AttributesFrozendict({'a': 5})
self.assertEqual(d.a, 5)
assert d.a == 5

with self.assertRaises(AttributeError):
with pytest.raises(AttributeError):
d.b

def test_setitem(self):
d = AttributesFrozendict()
with self.assertRaises(TypeError):
with pytest.raises(TypeError):
d['a'] = 5


Expand All @@ -37,7 +39,7 @@ async def async_fct():
pass


class TestEnsureCoroutine(unittest.TestCase):
class TestEnsureCoroutine:

def test_sync_func(self):
coro = ensure_coroutine(fct)
Expand All @@ -48,8 +50,6 @@ def test_async_func(self):
assert coro is async_fct

def test_callable_class(self):
"""
"""

class AsyncDummy:

Expand All @@ -60,8 +60,6 @@ async def __call__(self):
assert coro is AsyncDummy

def test_callable_object(self):
"""
"""

class AsyncDummy:

Expand All @@ -76,7 +74,11 @@ def test_functools_partial(self):
fct_wrap = functools.partial(fct)
coro = ensure_coroutine(fct_wrap)
assert coro is not fct_wrap
assert asyncio.iscoroutine(coro())
# The following will emit a RuntimeWarning ``coroutine 'ensure_coroutine.<locals>.wrap' was never awaited``
# since were not actually ever awaiting ``core`` but that is not the point of the test.
with warnings.catch_warnings():
warnings.simplefilter('ignore')
assert asyncio.iscoroutine(coro())


def test_load_function():
Expand Down

0 comments on commit b5d1fbe

Please sign in to comment.