]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add test to as_interface when no cls or methods
authorToni Karppi <karppitoni@gmail.com>
Thu, 21 Feb 2019 19:22:48 +0000 (14:22 -0500)
committersqla-tester <sqla-tester@sqlalchemy.org>
Thu, 21 Feb 2019 19:22:48 +0000 (14:22 -0500)
Fixes #4511

### Description
The `as_interface` function requires that an argument be provided for at least one of the parameters `cls` or `methods`. There was no test that tested the case when neither of these arguments were provided.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #4512
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4512
Pull-request-sha: 156f6af95ede730d2e1a9d2c935c830cf3cfc96e

Change-Id: Ifa23dbe1dbe9a824fe680e4947b81c96a50c133f

test/base/test_utils.py

index b27379248d3bfdc2546a32516fc16de7facf0f47..e96162703bc6f05000c322174de0f2951ef22a1f 100644 (file)
@@ -2305,6 +2305,10 @@ class AsInterfaceTest(fixtures.TestBase):
     class Object(object):
         pass
 
+    def test_no_cls_no_methods(self):
+        obj = object()
+        assert_raises(TypeError, util.as_interface, obj)
+
     def test_instance(self):
         obj = object()
         assert_raises(TypeError, util.as_interface, obj, cls=self.Something)