Xqt added a comment.

@Mpaa: Thanks for your proposal but the unittest fails then:

FAIL: test_filter_settings (__main__.TestEventStreamsSettingTests)
Test EventStreams filter settings.
----------------------------------------------------------------------
Traceback (most recent call last):
  File ".\tests\eventstreams_tests.py", line 142, in test_filter_settings
    self.assertIsInstance(self.es.filter['all'][0], FunctionType)
AssertionError: functools.partial(<function EventStreams.register_filter.<locals>._do_equal at 0x05287390>, key='foo', value='bar') is not an instance of <class 'function'>

the code snipped was

...
        def _do_is(e, key=None, value=None):
            return key in e and e[key] is value
        def _do_equal(e, key=None, value=None):
            return key in e and e[key] == value
        def _do_in(e, key=None, value=None):
            return key in e and e[key] in value
...
        for key, value in kwargs.items():
            # append function for singletons
            if isinstance(value, (bool, type(None))):
                self.filter[ftype].append(
                    partial(_do_is, key=key, value=value))                
            # append function for a single value
            elif isinstance(value, (StringTypes, int)):
                self.filter[ftype].append(
                    partial(_do_equal, key=key, value=value))                
            # append function for an iterable as value
            else:
                self.filter[ftype].append(
                    partial(_do_in, key=key, value=value))

TASK DETAIL
https://phabricator.wikimedia.org/T188832

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Xqt
Cc: gerritbot, Mpaa, zhuyifei1999, valhallasw, Dalba, Ottomata, Aklapper, Zoranzoki21, Xqt, pywikibot-bugs-list, Giuliamocci, Adrian1985, Cpaulf30, Baloch007, Darkminds3113, Lordiis, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, Magul, Tbscho, rafidaslam, MayS, Lewizho99, Mdupont, JJMC89, Maathavan, Avicennasis, jayvdb, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to