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

WIP: Port to plain unittest and py3k-compatible (py2k is supported as well) #11

Closed
wants to merge 2 commits into from

Conversation

mcepl
Copy link

@mcepl mcepl commented Apr 22, 2020

Still not completely finished, but this is too much for my very limited understanding of the package.

Could I ask for help with finish this, please?

[    4s] + py.test-3.8 --ignore=_build.python2 --ignore=_build.python3 --ignore=_build.pypy3 -v
[    4s] ============================= test session starts ==============================
[    4s] platform linux -- Python 3.8.2, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- /usr/bin/python3
[    4s] cachedir: .pytest_cache
[    4s] rootdir: /home/abuild/rpmbuild/BUILD/fudge-1.1.1
[    4s] collecting ... collected 203 items
[    4s] 
[    4s] fudge/tests/test_fudge.py::test_decorator_on_def FAILED                  [  0%]

[ ... ]

[    5s] 
[    5s] =================================== FAILURES ===================================
[    5s] ____________________________ test_decorator_on_def _____________________________
[    5s] 
[    5s]     def test_decorator_on_def():
[    5s]         class holder:
[    5s]             test_called = False
[    5s]     
[    5s]         bobby = fudge.Fake()
[    5s]         bobby.expects("suzie_called")
[    5s]     
[    5s]         @fudge.with_fakes
[    5s]         def some_test():
[    5s]             try:
[    5s]                 holder.test_called = True
[    5s]             except AssertionError:
[    5s]                 pass
[    5s]             else:
[    5s]                 raise AssertionError("Didn't raise AssertionError")
[    5s]     
[    5s]         assert some_test.__name__ == 'some_test'
[    5s] >       some_test()
[    5s] 
[    5s] fudge/tests/test_fudge.py:27: 
[    5s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    5s] fudge/__init__.py:171: in apply_clear_and_verify
[    5s]     method(*args, **kw)
[    5s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    5s] 
[    5s]     @fudge.with_fakes
[    5s]     def some_test():
[    5s]         try:
[    5s]             holder.test_called = True
[    5s]         except AssertionError:
[    5s]             pass
[    5s]         else:
[    5s] >           raise AssertionError("Didn't raise AssertionError")
[    5s] E           AssertionError: Didn't raise AssertionError
[    5s] 
[    5s] fudge/tests/test_fudge.py:24: AssertionError
[    5s] ____________ TestPatchedFakes.test_expectations_are_always_cleared _____________
[    5s] 
[    5s] self = <fudge.tests.test_fudge.TestPatchedFakes testMethod=test_expectations_are_always_cleared>
[    5s] 
[    5s]     def test_expectations_are_always_cleared(self):
[    5s]     
[    5s]         class holder:
[    5s]             test_called = False
[    5s]     
[    5s]         @fudge.patch('shutil.copy')
[    5s]         def some_test(copy):
[    5s]             with self.assertRaises(RuntimeError):
[    5s]                 holder.test_called = True
[    5s]                 copy.expects_call()
[    5s]                 raise RuntimeError
[    5s]     
[    5s] >       some_test()
[    5s] 
[    5s] fudge/tests/test_fudge.py:1171: 
[    5s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    5s] fudge/patcher.py:86: in caller
[    5s]     self.__exit__(None, None, None)
[    5s] fudge/patcher.py:113: in __exit__
[    5s]     fudge.verify()
[    5s] fudge/__init__.py:132: in verify
[    5s]     registry.verify()
[    5s] fudge/__init__.py:98: in verify
[    5s]     exp.assert_called()
[    5s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    5s] 
[    5s] self = fake:shutil.copy()
[    5s] 
[    5s]     def assert_called(self):
[    5s]         if not self.was_called:
[    5s] >           raise AssertionError("%s was not called" % (self))
[    5s] E           AssertionError: fake:shutil.copy() was not called
[    5s] 
[    5s] fudge/__init__.py:456: AssertionError
[    5s] _________ TestNonPatchedFakeTest.test_expectations_are_always_cleared __________
[    5s] 
[    5s] self = <fudge.tests.test_fudge.TestNonPatchedFakeTest testMethod=test_expectations_are_always_cleared>
[    5s] 
[    5s]     def test_expectations_are_always_cleared(self):
[    5s]     
[    5s]         class holder:
[    5s]             test_called = False
[    5s]     
[    5s]         @fudge.test
[    5s]         def some_test():
[    5s]             with self.assertRaises(RuntimeError):
[    5s]                 holder.test_called = True
[    5s]                 fake = fudge.Fake('db').expects('save')
[    5s]                 raise RuntimeError
[    5s]     
[    5s] >       some_test()
[    5s] 
[    5s] fudge/tests/test_fudge.py:1260: 
[    5s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    5s] fudge/__init__.py:210: in clear_and_verify
[    5s]     verify() # if no exceptions
[    5s] fudge/__init__.py:132: in verify
[    5s]     registry.verify()
[    5s] fudge/__init__.py:98: in verify
[    5s]     exp.assert_called()
[    5s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[    5s] 
[    5s] self = fake:db.save()
[    5s] 
[    5s]     def assert_called(self):
[    5s]         if not self.was_called:
[    5s] >           raise AssertionError("%s was not called" % (self))
[    5s] E           AssertionError: fake:db.save() was not called
[    5s] 
[    5s] fudge/__init__.py:456: AssertionError
[    5s] _________________ TestRegistry.test_global_clear_expectations __________________
[    5s] 
[    5s] self = <fudge.tests.test_registry.TestRegistry testMethod=test_global_clear_expectations>
[    5s] 
[    5s]     def test_global_clear_expectations(self):
[    5s]         exp = ExpectedCall(self.fake, 'callMe')
[    5s]         exp()
[    5s]         self.assertEqual(len(self.reg.get_expected_calls()), 1)
[    5s]         exp_order = ExpectedCallOrder(self.fake)
[    5s]         self.reg.remember_expected_call_order(exp_order)
[    5s] >       self.assertEqual(self.reg.get_expected_call_order().keys(), [self.fake])
[    5s] E       AssertionError: dict_keys([fake:unnamed]) != [fake:unnamed]
[    5s] 
[    5s] fudge/tests/test_registry.py:87: AssertionError
[    5s] ======================== 4 failed, 199 passed in 0.92s =========================

bmwiedemann added a commit to bmwiedemann/openSUSE that referenced this pull request Apr 23, 2020
https://build.opensuse.org/request/show/796348
by user mcepl + dimstar_suse
- Add remove_nose.patch which removes need to use nose, and ports
  the package to py3k-compatible syntax. (gh#fudge-py/fudge#11)
@jayvdb jayvdb mentioned this pull request Jan 24, 2021
@mcepl mcepl closed this by deleting the head repository Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant