class TestRegistry(RootNodeTestCase): def setUp(self): from widgy import Registry self.registry = Registry() class Test(Content): pass self.cls = Test def test_register(self): self.registry.register(self.cls) self.assertIn(self.cls, self.registry) def test_unregister(self): self.registry.register(self.cls) self.registry.unregister(self.cls) self.assertNotIn(self.cls, self.registry) def test_register_twice(self): self.registry.register(self.cls) with self.assertRaises(Exception): self.registry.register(self.cls) def test_unregister_not_registered(self): with self.assertRaises(Exception): self.registry.unregister(self.cls)
class TestRegistry(RootNodeTestCase): def setUp(self): from widgy import Registry self.registry = Registry() class Test(Content): pass self.cls = Test def test_register(self): self.registry.register(self.cls) self.assertIn(self.cls, self.registry) self.registry.raise_deferred_exception() def test_unregister(self): self.registry.register(self.cls) self.registry.unregister(self.cls) self.assertNotIn(self.cls, self.registry) self.registry.raise_deferred_exception() def test_register_twice(self): self.registry.register(self.cls) with mock.patch('sys.stderr') as stderr: with self.assertRaises(Exception): self.registry.register(self.cls) self.registry.raise_deferred_exception() stderr.write.assert_called_once() def test_unregister_not_registered(self): with mock.patch('sys.stderr') as stderr: with self.assertRaises(Exception): self.registry.unregister(self.cls) self.registry.raise_deferred_exception() stderr.write.assert_called_once()
class TestRegistry(RootNodeTestCase): def setUp(self): from widgy import Registry self.registry = Registry() class Test(Content): pass self.cls = Test def test_register(self): self.registry.register(self.cls) self.assertIn(self.cls, self.registry) def test_unregister(self): self.registry.register(self.cls) self.registry.unregister(self.cls) self.assertNotIn(self.cls, self.registry) def test_register_twice(self): self.registry.register(self.cls) with self.assertRaises(Exception): self.registry.register(self.cls) def test_unregister_not_registered(self): with self.assertRaises(Exception): self.registry.unregister(self.cls)
class TestRegistry(RootNodeTestCase): def setUp(self): from widgy import Registry self.registry = Registry() class Test(Content): pass self.cls = Test def test_register(self): self.registry.register(self.cls) self.assertIn(self.cls, self.registry) self.registry.raise_deferred_exception() def test_unregister(self): self.registry.register(self.cls) self.registry.unregister(self.cls) self.assertNotIn(self.cls, self.registry) self.registry.raise_deferred_exception() def test_register_twice(self): self.registry.register(self.cls) with mock.patch('sys.stderr') as stderr: with self.assertRaises(Exception): self.registry.register(self.cls) self.registry.raise_deferred_exception() stderr.write.assert_called_once() def test_unregister_not_registered(self): with mock.patch('sys.stderr') as stderr: with self.assertRaises(Exception): self.registry.unregister(self.cls) self.registry.raise_deferred_exception() stderr.write.assert_called_once()