gabrielfalcao / sure

sophisticated automated test library and runner
https://sure.readthedocs.io
GNU General Public License v3.0
696 stars 74 forks source link

python3.10 test failures #173

Open jsmolic opened 3 years ago

jsmolic commented 3 years ago

When running tests with Python 3.10.0b1, I get the following errors:

======================================================================
ERROR: this(None).should.be.none
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/tests/test_assertion_builder.py", line 140, in test_should_be_a
    assert this([]).should.be.a('collections.Iterable')
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 385, in wrapper
    value = func(self, *args, **kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 721, in an
    klass = reduce(getattr, items, __import__(first))
AttributeError: module 'collections' has no attribute 'Iterable'

======================================================================
FAIL: issues.test_issue_104.test_issue_104
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 385, in wrapper
    value = func(self, *args, **kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 636, in within
    raise AssertionError((
AssertionError: world.should.be.within(hello world, ) must be called with either a iterable:
world.should.be.within([1, 2, 3, 4])
or with a range of numbers:world.should.be.within(1, 3000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 385, in wrapper
    value = func(self, *args, **kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 888, in contain
    return expect(what).to.be.within(obj)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 387, in wrapper
    raise AssertionError(e)
AssertionError: world.should.be.within(hello world, ) must be called with either a iterable:
world.should.be.within([1, 2, 3, 4])
or with a range of numbers:world.should.be.within(1, 3000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/tests/issues/test_issue_104.py", line 12, in test_issue_104
    expect("hello world").to.contain("world")
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 387, in wrapper
    raise AssertionError(e)
AssertionError: world.should.be.within(hello world, ) must be called with either a iterable:
world.should.be.within([1, 2, 3, 4])
or with a range of numbers:world.should.be.within(1, 3000)

======================================================================
FAIL: expect('some string').to.contain('tri')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 385, in wrapper
    value = func(self, *args, **kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 636, in within
    raise AssertionError((
AssertionError: tri.should.be.within(some string, ) must be called with either a iterable:
tri.should.be.within([1, 2, 3, 4])
or with a range of numbers:tri.should.be.within(1, 3000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 385, in wrapper
    value = func(self, *args, **kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 888, in contain
    return expect(what).to.be.within(obj)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 387, in wrapper
    raise AssertionError(e)
AssertionError: tri.should.be.within(some string, ) must be called with either a iterable:
tri.should.be.within([1, 2, 3, 4])
or with a range of numbers:tri.should.be.within(1, 3000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/tests/test_assertion_builder.py", line 570, in test_match_contain
    assert this("some string").should.contain("tri")
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 387, in wrapper
    raise AssertionError(e)
AssertionError: tri.should.be.within(some string, ) must be called with either a iterable:
tri.should.be.within([1, 2, 3, 4])
or with a range of numbers:tri.should.be.within(1, 3000)

======================================================================
FAIL: do not patch already existing class attributes with same name
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 385, in wrapper
    value = func(self, *args, **kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 636, in within
    raise AssertionError((
AssertionError: when.should.be.within({'__module__': 'test_cpython_patches', 'when': 42, 'shouldnt': 43, 'bar': 'bar', '__dict__': <attribute '__dict__' of 'Foo' objects>, '__weakref__': <attribute '__weakref__' of 'Foo' objects>, '__doc__': None}, ) must be called with either a iterable:
when.should.be.within([1, 2, 3, 4])
or with a range of numbers:when.should.be.within(1, 3000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 385, in wrapper
    value = func(self, *args, **kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 888, in contain
    return expect(what).to.be.within(obj)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 387, in wrapper
    raise AssertionError(e)
AssertionError: when.should.be.within({'__module__': 'test_cpython_patches', 'when': 42, 'shouldnt': 43, 'bar': 'bar', '__dict__': <attribute '__dict__' of 'Foo' objects>, '__weakref__': <attribute '__weakref__' of 'Foo' objects>, '__doc__': None}, ) must be called with either a iterable:
when.should.be.within([1, 2, 3, 4])
or with a range of numbers:when.should.be.within(1, 3000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/tests/test_cpython_patches.py", line 45, in test_shouldnt_overwrite_class_attributes
    Foo.__dict__.should.contain('when')
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 387, in wrapper
    raise AssertionError(e)
AssertionError: when.should.be.within({'__module__': 'test_cpython_patches', 'when': 42, 'shouldnt': 43, 'bar': 'bar', '__dict__': <attribute '__dict__' of 'Foo' objects>, '__weakref__': <attribute '__weakref__' of 'Foo' objects>, '__doc__': None}, ) must be called with either a iterable:
when.should.be.within([1, 2, 3, 4])
or with a range of numbers:when.should.be.within(1, 3000)

======================================================================
FAIL: sure.that_with_context() when no context is given it fails
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/old.py", line 129, in raises
    self._src(*self._callable_args, **self._callable_kw)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 152, in wrap
    res = test.apply(context)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/__init__.py", line 117, in apply
    return self.callback(*args, **self.kwargs)
TypeError: test_context_is_not_optional.<locals>.it_crashes() takes 0 positional arguments but 1 was given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/tests/test_old_api.py", line 59, in test_context_is_not_optional
    assert that(it_crashes).raises(
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/old.py", line 148, in raises
    raise AssertionError('''
AssertionError: <function test_context_is_not_optional.<locals>.it_crashes at 0x7fec6b094160> raised TypeError, but the exception message does not
                    match.

EXPECTED:
the function it_crashes defined at test_old_api.py line 56, is being decorated by either @that_with_context or @scenario, so it should take at least 1 parameter, which is the test context

GOT:
test_context_is_not_optional.<locals>.it_crashes() takes 0 positional arguments but 1 was given

======================================================================
FAIL: that() has(object)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/tests/test_old_api.py", line 153, in test_that_has
    assert that(name).has("john")
  File "/var/tmp/portage/dev-python/sure-1.4.11/work/sure-1.4.11/sure/old.py", line 75, in wrap
    assert ret, msg % (self._src, what)
AssertionError: 'john' should have 'john', but have not
yan12125 commented 2 years ago

FWIW, I got only one failure for python-sure 2.0 on python 3.10.0, and it can be fixed by this patch: https://github.com/gabrielfalcao/sure/issues/169#issuecomment-987889068