示例#1
0
    def test_error_is_raised(self):
        found_sigs = enum_all()
        # Make sure that errors are actually raised.
        search = list(found_sigs.keys())
        pos = 42  # arbitrary and historycal, could be 0 as well

        # We try all variants:
        while type(found_sigs[search[pos]]) is not tuple:
            pos += 1
        tuple_key = search[pos]
        while type(found_sigs[search[pos]]) is not list:
            pos += 1
        list_key = search[pos]

        test_sigs = found_sigs.copy()
        test_sigs.pop(tuple_key)
        with isolate_warnings(), suppress_warnings():
            self._do_the_test(test_sigs)
            self.assertTrue(check_warnings(), "you warn about too few entries")

        test_sigs = found_sigs.copy()
        test_sigs["whatnot"] = ("nothing", "real")
        with isolate_warnings(), suppress_warnings():
            self._do_the_test(test_sigs)
            self.assertFalse(check_warnings(), "you ignore too many entries")

        test_sigs = found_sigs.copy()
        repl = test_sigs[list_key]
        repl.pop(0)
        test_sigs[list_key] = repl
        with isolate_warnings(), suppress_warnings():
            self._do_the_test(test_sigs)
            # An arity that is now missing is an error.
            self.assertTrue(check_warnings(),
                            "you warn when arity got smaller")

        test_sigs = found_sigs.copy()
        repl = test_sigs[list_key]
        repl = repl[0]
        assert type(repl) is tuple
        test_sigs[list_key] = repl
        with isolate_warnings(), suppress_warnings():
            self._do_the_test(test_sigs)
            # An arity that is now missing is an error.
            self.assertTrue(check_warnings(),
                            "you warn when list degraded to tuple")

        test_sigs = found_sigs.copy()
        repl = test_sigs[list_key]
        repl = repl + repl
        test_sigs[list_key] = repl
        with isolate_warnings(), suppress_warnings():
            self._do_the_test(test_sigs)
            # More arities are ignored, because we might test an older version.
            self.assertFalse(check_warnings(),
                             "you ignore when arity got bigger")
示例#2
0
 def testAllSignaturesCanBuild(self):
     with isolate_warnings():
         # This test touches all attributes
         result = enum_all()
         # We omit the number of functions test.
         # That is replaced by existence_test.py .
         for mod_name, count in result.items():
             pass
         # If an attribute could not be computed, then we will have a warning
         # in the warningregistry.
         if check_warnings():
             raise RuntimeError("There are errors, see above.")
示例#3
0
 def test_signatures(self):
     found_sigs = enum_all()
     with isolate_warnings():
         for key, value in sig_exists.dict.items():
             name = key.rsplit(".", 1)[-1]
             if name in ("next", "__next__"): # ignore problematic cases
                 continue
             if key not in found_sigs:
                 warn("missing key: '{}'".format(key))
             elif isinstance(value, list) and len(value) != len(found_sigs[key]):
                 warn("multi-signature count mismatch: '{}'".format(key))
         if is_ci and check_warnings():
             raise RuntimeError("There are errors, see above.")
示例#4
0
 def test_error_is_raised(self):
     found_sigs = enum_all()
     # make sure that errors are actually raised
     found_sigs.pop(list(found_sigs.keys())[42])
     with isolate_warnings(), suppress_warnings():
         for key, value in sig_exists.dict.items():
             name = key.rsplit(".", 1)[-1]
             if name in ("next", "__next__"): # ignore problematic cases
                 continue
             if key not in found_sigs:
                 warn("missing key: '{}'".format(key))
             elif isinstance(value, list) and len(value) != len(found_sigs[key]):
                 warn("multi-signature count mismatch: '{}'".format(key))
         self.assertTrue(check_warnings())
示例#5
0
 def test_signatures(self):
     found_sigs = enum_all()
     with isolate_warnings():
         self._do_the_test(found_sigs)
         if is_ci and check_warnings():
             raise RuntimeError("There are errors, see above.")