def test_repeat(self, space, api): def test(seq, count): w_seq = space.wrap(seq) w_repeated = api.PySequence_Repeat(w_seq, count) assert space.eq_w(w_repeated, space.wrap(seq * count)) test((1, 2, 3, 4), 3) test([1, 2, 3, 4], 3)
def w_check_max_buffer_size_deprecation(self, test): import _io import _warnings def simplefilter(action, category): _warnings.filters.insert(0, (action, None, category, None, 0)) simplefilter('error', DeprecationWarning) try: test(_io.BytesIO(), 8, 12) except DeprecationWarning as e: assert 'max_buffer_size is deprecated' in str(e) else: assert False, 'Expected DeprecationWarning' finally: simplefilter('default', DeprecationWarning)
def testContextDecorator(): """Test the with_extension function decorator.""" class Test1ExtensionNode(mdp.ExtensionNode): extension_name = "__test1" def _testtest(self): pass @mdp.with_extension("__test1") def test(): return mdp.get_active_extensions() # check that the extension is activated assert mdp.get_active_extensions() == [] active = test() assert active == ["__test1"] assert mdp.get_active_extensions() == [] # check that it is only deactiveted if it was activated there mdp.activate_extension("__test1") active = test() assert active == ["__test1"] assert mdp.get_active_extensions() == ["__test1"]