-
Notifications
You must be signed in to change notification settings - Fork 22
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
0.2.1: test suite is using deprecated nose
module and pytest is failing in one unit
#46
Comments
After add + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-traittypes-0.2.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-traittypes-0.2.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --ignore traittypes/tests/test_import_errors.py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1
collected 25 items
traittypes/tests/test_traittypes.py .....F................. [ 92%]
traittypes/tests/test_validators.py .. [100%]
================================================================================= FAILURES =================================================================================
_______________________________________________________________________ TestIntArray.test_bad_values _______________________________________________________________________
self = <traittypes.tests.test_traittypes.TestIntArray testMethod=test_bad_values>
def test_bad_values(self):
if hasattr(self, '_bad_values'):
for value in self._bad_values:
try:
> self.assertRaises(TraitError, self.assign, value)
/usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <traittypes.tests.test_traittypes.TestIntArray testMethod=test_bad_values>, expected_exception = <class 'traitlets.traitlets.TraitError'>
args = (<bound method TraitTestBase.assign of <traittypes.tests.test_traittypes.TestIntArray testMethod=test_bad_values>>, [1, [0, 0]]), kwargs = {}, context = None
def assertRaises(self, expected_exception, *args, **kwargs):
"""Fail unless an exception of class expected_exception is raised
by the callable when invoked with specified positional and
keyword arguments. If a different type of exception is
raised, it will not be caught, and the test case will be
deemed to have suffered an error, exactly as for an
unexpected exception.
If called with the callable and arguments omitted, will return a
context object used like this::
with self.assertRaises(SomeException):
do_something()
An optional keyword argument 'msg' can be provided when assertRaises
is used as a context object.
The context manager keeps a reference to the exception as
the 'exception' attribute. This allows you to inspect the
exception after the assertion::
with self.assertRaises(SomeException) as cm:
do_something()
the_exception = cm.exception
self.assertEqual(the_exception.error_code, 3)
"""
context = _AssertRaisesContext(expected_exception, self)
try:
> return context.handle('assertRaises', args, kwargs)
/usr/lib64/python3.8/unittest/case.py:816:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = None, name = 'assertRaises', args = [[1, [0, 0]]], kwargs = {}
def handle(self, name, args, kwargs):
"""
If args is empty, assertRaises/Warns is being used as a
context manager, so check for a 'msg' kwarg and return self.
If args is not empty, call a callable passing positional and keyword
arguments.
"""
try:
if not _is_subtype(self.expected, self._base_type):
raise TypeError('%s() arg 1 must be %s' %
(name, self._base_type_str))
if not args:
self.msg = kwargs.pop('msg', None)
if kwargs:
raise TypeError('%r is an invalid keyword argument for '
'this function' % (next(iter(kwargs)),))
return self
callable_obj, *args = args
try:
self.obj_name = callable_obj.__name__
except AttributeError:
self.obj_name = str(callable_obj)
with self:
> callable_obj(*args, **kwargs)
/usr/lib64/python3.8/unittest/case.py:202:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x7fe06b81b6d0>, exc_type = None, exc_value = None, tb = None
def __exit__(self, exc_type, exc_value, tb):
if exc_type is None:
try:
exc_name = self.expected.__name__
except AttributeError:
exc_name = str(self.expected)
if self.obj_name:
> self._raiseFailure("{} not raised by {}".format(exc_name,
self.obj_name))
/usr/lib64/python3.8/unittest/case.py:224:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <unittest.case._AssertRaisesContext object at 0x7fe06b81b6d0>, standardMsg = 'TraitError not raised by assign'
def _raiseFailure(self, standardMsg):
msg = self.test_case._formatMessage(self.msg, standardMsg)
> raise self.test_case.failureException(msg)
E AssertionError: TraitError not raised by assign
/usr/lib64/python3.8/unittest/case.py:164: AssertionError
During handling of the above exception, another exception occurred:
self = <traittypes.tests.test_traittypes.TestIntArray testMethod=test_bad_values>
def test_bad_values(self):
if hasattr(self, '_bad_values'):
for value in self._bad_values:
try:
self.assertRaises(TraitError, self.assign, value)
except AssertionError:
> assert False, value
E AssertionError: [1, [0, 0]]
E assert False
/usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1197: AssertionError
============================================================================= warnings summary =============================================================================
traittypes/traittypes.py:20
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/traittypes.py:20: DeprecationWarning:
Sentinel is not a public part of the traitlets API.
It was published by mistake, and may be removed in the future.
Empty = Sentinel('Empty', 'traittypes',
../../../../../usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1740
/usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1740: DeprecationWarning: Keyword `trait` is deprecated in traitlets 5.0, use `value_trait` instead
value = Dict(trait=Unicode(),
../../../../../usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1755
/usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1755: DeprecationWarning: Keyword `traits` is deprecated in traitlets 5.0, use `per_key_traits` instead
value = Dict(traits={'foo': Int()},
../../../../../usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1785
/usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1785: DeprecationWarning: Keyword `trait` is deprecated in traitlets 5.0, use `value_trait` instead
value = Dict(trait=Unicode(),
../../../../../usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1785
/usr/lib/python3.8/site-packages/traitlets/tests/test_traitlets.py:1785: DeprecationWarning: Keyword `traits` is deprecated in traitlets 5.0, use `per_key_traits` instead
value = Dict(trait=Unicode(),
traittypes/tests/test_traittypes.py:20
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/tests/test_traittypes.py:20: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
value = Array().tag(dtype=np.int)
traittypes/tests/test_traittypes.py::TestIntArray::test_bad_values
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/traittypes.py:95: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
r = np.asarray(value, dtype=self.dtype)
traittypes/tests/test_traittypes.py::TestArray::test_initial_values
traittypes/tests/test_traittypes.py::TestDataFrame::test_initial_values
traittypes/tests/test_traittypes.py::TestSeries::test_initial_values
traittypes/tests/test_traittypes.py::TestDataset::test_initial_values
traittypes/tests/test_traittypes.py::TestDataArray::test_initial_values
/usr/lib/python3.8/site-packages/traitlets/traitlets.py:577: DeprecationWarning: Explicit using of Undefined as the default value is deprecated in traitlets 5.0, and may cause exceptions in the future.
return self.get(obj, cls)
traittypes/tests/test_traittypes.py::TestDataFrame::test_allow_none
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/tests/test_traittypes.py:140: DeprecationWarning: metadata {'dtype': None} was set from the constructor. With traitlets 4.1, metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
bar = DataFrame()
traittypes/tests/test_traittypes.py::TestSeries::test_allow_none
traittypes/tests/test_traittypes.py::TestSeries::test_allow_none
traittypes/tests/test_traittypes.py::TestSeries::test_initial_values
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/traittypes.py:166: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
default_value = klass()
traittypes/tests/test_traittypes.py::TestSeries::test_initial_values
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/traittypes.py:168: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
default_value = klass(default_value)
traittypes/tests/test_traittypes.py::TestSeries::test_initial_values
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/tests/test_traittypes.py:170: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
self.assertTrue(foo.a.equals(pd.Series()))
traittypes/tests/test_traittypes.py::TestSeries::test_initial_values
/home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1/traittypes/tests/test_traittypes.py:172: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
self.assertTrue(foo.c.equals(pd.Series([])))
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
FAILED traittypes/tests/test_traittypes.py::TestIntArray::test_bad_values - AssertionError: [1, [0, 0]]
================================================================ 1 failed, 24 passed, 19 warnings in 0.93s ================================================================= |
kloczek
changed the title
0.2.1: test suite is using deprecated
0.2.1: test suite is using deprecated Apr 7, 2022
nose
modulenose
module and pytest is failing in one unit
Just stated testing master commits because I found some chnges removing use + /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1
collected 3 items / 1 error
========================================================================================== ERRORS ===========================================================================================
___________________________________________________________________ ERROR collecting traittypes/tests/test_traittypes.py ____________________________________________________________________
traittypes/tests/test_traittypes.py:19: in <module>
class IntArrayTrait(HasTraits):
traittypes/tests/test_traittypes.py:20: in IntArrayTrait
value = Array().tag(dtype=np.int)
/usr/lib64/python3.8/site-packages/numpy/__init__.py:284: in __getattr__
raise AttributeError("module {!r} has no attribute "
E AttributeError: module 'numpy' has no attribute 'int'
================================================================================== short test summary info ==================================================================================
ERROR traittypes/tests/test_traittypes.py - AttributeError: module 'numpy' has no attribute 'int'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 1 error in 1.77s ====================================================================================== |
After add temporary that fil to --ignore list test suite seems is ok + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-traittypes-0.2.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-traittypes-0.2.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' --ignore traittypes/tests/test_traittypes.py
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/traittypes-0.2.1
collected 3 items
traittypes/tests/test_import_errors.py . [ 33%]
traittypes/tests/test_validators.py .. [100%]
===================================================================================== 3 passed in 0.17s ===================================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like
traittypes
is one onf the only few modules still using nose wich is no longer maintained and should not be used with python 3.x https://nose.readthedocs.io/en/latest/On migration from
nose
topytest
can be used https://github.com/schollii/nose2pytest/In above output it is possible to as well see few warnings.
The text was updated successfully, but these errors were encountered: