• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

macisamuele / TestSlide / 5322770528
94%
master: 94%

Build:
Build:
LAST BUILD BRANCH: export-D46856794
DEFAULT BRANCH: master
Ran 20 Jun 2023 12:53PM UTC
Jobs 4
Files 11
Run time 1s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
  cancel
5322770528

push

github

facebook-github-bot
Add mock_callable and mock_async_callable support for slotted classes

Summary:
This PR has the objective of supporting `self.mock_callable` and `self.mock_async_callable` for methods of slotted classes.

Before the PR mocking was not possible as `testslide` implementation assumed the presence of `__dict__` (which cannot be ensured on slotted classes).

## Test plan
```
(venv) maci:testslide/ (maci-add-support-for-slotted-classes) $ git co -f HEAD~1 testslide
Updated 1 path from ad55cd4
(venv) maci:testslide/ (maci-add-support-for-slotted-classes✗) $ git reset
Unstaged changes after reset:
M	testslide/mock_callable.py
(venv) maci:testslide/ (maci-add-support-for-slotted-classes✗) $ git diff
(venv) maci:testslide/ (maci-add-support-for-slotted-classes✗) $ git diff | cat
 diff --git a/testslide/mock_callable.py b/testslide/mock_callable.py
index 12fc9c9..87cf2f4 100644
 --- a/testslide/mock_callable.py
+++ b/testslide/mock_callable.py
@@ -776,14 +776,8 @@ class _MockCallableDSL:
             self.type_validation or self.type_validation is None,
         )

-        if isinstance(self._target, (Mock, StrictMock)) or not hasattr(
-            self._target, "__slots__"
-        ):
-            restore = self._method in self._target.__dict__
-            restore_value = self._target.__dict__.get(self._method, None)
-        else:
-            restore = self._method in self._target.__slots__
-            restore_value = getattr(self._target, self._method)
+        restore = self._method in self._target.__dict__
+        restore_value = self._target.__dict__.get(self._method, None)

         if inspect.isclass(self._target):
             new_value = staticmethod(new_value)  # type: ignore
(venv) maci:testslide/ (maci-add-support-for-slotted-classes✗) $ make tests/mock_callable_testslide.py
COVERAGE ERASE
TESTSLIDE tests/mock_callable_testslide.py
mock_callable()
  patching private functions raises valueerror
  patching private functions with allow private
  p... (continued)

2663 of 2841 relevant lines covered (93.73%)

3.74 hits per line

Jobs
ID Job ID Ran Files Coverage
1 5322770528.1 20 Jun 2023 12:53PM UTC 0
93.38
2 5322770528.2 20 Jun 2023 12:53PM UTC 0
93.63
3 5322770528.3 20 Jun 2023 12:53PM UTC 0
93.38
4 5322770528.4 20 Jun 2023 12:53PM UTC 0
93.38
Source Files on build 5322770528
Detailed source file information is not available for this build.
  • Back to Repo
  • 4f259286 on github
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc