How to use the pynq.guard.Guard.accepts_only function in pynq

To help you get started, we’ve selected a few pynq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heynemann / pynq / tests / unit / test_guard.py View on Github external
def test_accepts_only_with_message(self):
        items = ["a", "b"]
        items_failing = ["a", "b", 1]
        message = "There should be only strings."
        
        Guard.accepts_only(items, [str], message)
        
        self.assertRaisesEx(ValueError, Guard.accepts_only, items_failing, [str], message, exc_pattern=re.compile(message))
github heynemann / pynq / tests / unit / test_guard.py View on Github external
def test_accepts_only_with_message(self):
        items = ["a", "b"]
        items_failing = ["a", "b", 1]
        message = "There should be only strings."
        
        Guard.accepts_only(items, [str], message)
        
        self.assertRaisesEx(ValueError, Guard.accepts_only, items_failing, [str], message, exc_pattern=re.compile(message))
github heynemann / pynq / tests / unit / test_guard.py View on Github external
def test_accepts_only_without_message(self):
        items = ["a", "b"]
        items_failing = ["a", "b", 1]
        message = u"All arguments in the given collection should be of type\(s\) \[str\] and at least one of them isn't."
        
        Guard.accepts_only(items, [str])
        
        self.assertRaisesEx(ValueError, Guard.accepts_only, items_failing, [str], exc_pattern=re.compile(message))
github heynemann / pynq / pynq / __init__.py View on Github external
def select(self, *cols):
        empty_message = "Selecting with no fields is not valid. " \
                                  + "When using From(provider).select method, " \
                                  + "please provide a list of expressions or strings as fields."
        Guard.against_empty(cols, empty_message)
        for col in cols:
            Guard.against_empty(col, empty_message)
        Guard.accepts_only(cols, [str, Expression], "Selecting with invalid type. " \
                                                    + "When using From(provider).select method, " \
                                                    + "please provide a list of expressions or strings as fields.")
                                                    
        return self.provider.parse(self, action=Actions.Select, cols=cols)